first, are you sure the code is even getting that far? double check the
Status string in the code to make sure it matches *exactly* what will be
entered in the Status control on the form. if the Status control is a
combobox control, the stored values may be numbers, not text, so double
check that as well.
if the Status value checks out okay, suggest you replace the two lines of
code
If IsNull(Me!BodyNumber) Then
and
ElseIf IsNull(Me!Countermeasure) Then
with
If Len(Me!BodyNumber & "") = 0 Then
and
ElseIf Len(Me!Countermeasure & "") = 0 Then
though it's generally better to set the AllowZeroLengthString property to
No, in every field in your table that is a Text datatype.
hth
try
Private Sub SubmitFitConcern_Click()
If Len(Me!CountermeasureDate & "") = 0 Then
MsgBox "You must select a CountermeasureDate."
Exit Sub
ElseIf Me!CountermeasureDate < Me!RequestDate Then
MsgBox "The CountermeasureDatemust begreater" _
& "thanthe RequestDate."
Exit Sub
ElseIf Me!Status = "Closed-OK" Then
If IsNull(Me!BodyNumber) Then
MsgBox "You must input a Body Number " _
& "before you can close this Countermeasure."
Exit Sub
ElseIf IsNull(Me!Countermeasure) Then
MsgBox "You must indicate Countermeasure Details " _
& "before you can close this Countermeasure."
Exit Sub
End If
End If
SubmitCM
End Sub
hth
I am trying to us If IsNull to create requirements on a form that need
to be fulfilled, but
I don't think I have the "language" quite right. Can anyone help me
correct this?
Here is what I have so far:
Private Sub SubmitFitConcern_Click()
If Len([CountermeasureDate] & "") = 0 Then
MsgBox "You must select a CountermeasureDate."
Exit Sub
End If
If Len([CountermeasureDate] & "") < (RequestDate) Then
MsgBox "The CountermeasureDatemust begreaterthanthe
RequestDate."
Exit Sub
End If
If IsNull(BodyNumber) And (Status) = "Closed-OK" Then
MsgBox "You must input a Body Number before you can close this
Countermeasure."
Exit Sub
End If
If IsNull(Countermeasure) And (Status) = "Closed-OK" Then
MsgBox "You must indicate Countermeasure Details before you
can close this Countermeasure."
Exit Sub
End If
SubmitCM
End Sub
Thank you!- Hide quoted text -
- Show quoted text -
Thank you tina,
...but I still have a problem.....when I inserted the code into the
VBA editor
for the form and tested it, it did not recognize that the
Countermeasure
or BodyNumber boxes were empty or "null"....- Hide quoted text -
- Show quoted text -
Thank you, again...the Status box is a combo box. The user has a
choice
of three values - "Open", "Closed-OK" and "Closed-NG" (NG=No good).
Does this make a difference?- Hide quoted text -
Going through the debugger ....
Private Sub SubmitFitConcern_Click()
If Len([CountermeasureDate] & "") = 0 Then
MsgBox "You must select a CountermeasureDate."
Exit Sub
End If
If [CountermeasureDate] < (RequestDate) Then
MsgBox "The CountermeasureDatemust begreaterthanthe
RequestDate."
Exit Sub
End If
If [Status] = "Closed-OK" Then
gets to here and then jumps down to:
End If
SubmitCM
End Sub
completely missing:
If IsNull(BodyNumber) Then
MsgBox "You must input a Body Number before you can close
this Countermeasure."
Exit Sub
ElseIf IsNull(Countermeasure) Then
MsgBox "You must indicate Countermeasure Details before
you can close this Countermeasure."
Exit Sub
End If
.....so, something is missing here.....but I'm not sure what.....- Hide quoted text -
- Show quoted text -