If one thing and another thing

  • Thread starter Thread starter Hoopster
  • Start date Start date
H

Hoopster

I have two controls where if the 1st control says one thing and the 2nd
control is Null, I want to alert the user to check their data. Is this
possible?

If (Me.[Pass/Repair/Reject]) = "Repair" And (Me.[Repair/RejectComments]) Is
Null Then

Save_and_Mailpromt = MsgBox("Please Check Your Data. Cause Code Can Not
Be Empty When Total Number of Rework for this Cause Field Has Been Filled
In!", vbOK, "OhioData")

[Forms]![CellAudits]![RepairNumber].SetFocus

End If
 
Hoopster said:
I have two controls where if the 1st control says one thing and the 2nd
control is Null, I want to alert the user to check their data. Is this
possible?

If (Me.[Pass/Repair/Reject]) = "Repair" And (Me.[Repair/RejectComments])
Is
Null Then

Save_and_Mailpromt = MsgBox("Please Check Your Data. Cause Code Can Not
Be Empty When Total Number of Rework for this Cause Field Has Been Filled
In!", vbOK, "OhioData")

[Forms]![CellAudits]![RepairNumber].SetFocus

End If

You need to make one small change. Use the IsNull function instead of Is
Null (notice the space), which is only valid in queries.

If (Me.[Pass/Repair/Reject]) = "Repair" And
IsNull(Me.[Repair/RejectComments]) Then
 
It is certainly possible, but to test for the Control having a Null value,
you must use the IsNull function, to wit,

If (Me.[Pass/Repair/Reject]) = "Repair" And
IsNull(Me.[Repair/RejectComments]) Then

"Is Null" works in Query Criteria, but not in VBA code.

Larry Linson
Microsoft Office Access MVP
 
Just another tidbit that might come in handy for you when checking for null
values:

The following statement EXPLICITLY checks if a null value:
if isnull(Me.MyField.Value))=True Then

And Conversely you can check if a value is NOT NULL with:
if isnull(Me.MyField.Value))=False Then

Larry Linson said:
It is certainly possible, but to test for the Control having a Null value,
you must use the IsNull function, to wit,

If (Me.[Pass/Repair/Reject]) = "Repair" And
IsNull(Me.[Repair/RejectComments]) Then

"Is Null" works in Query Criteria, but not in VBA code.

Larry Linson
Microsoft Office Access MVP

Hoopster said:
I have two controls where if the 1st control says one thing and the 2nd
control is Null, I want to alert the user to check their data. Is this
possible?

If (Me.[Pass/Repair/Reject]) = "Repair" And (Me.[Repair/RejectComments])
Is
Null Then

Save_and_Mailpromt = MsgBox("Please Check Your Data. Cause Code Can Not
Be Empty When Total Number of Rework for this Cause Field Has Been Filled
In!", vbOK, "OhioData")

[Forms]![CellAudits]![RepairNumber].SetFocus

End If
 
Back
Top