If one thing and another thing

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
 
S

Stuart McCall

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
 
L

Larry Linson

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
 
C

CrazyAccessProgrammer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top