Hi Ofer,
Thanks for the help. I cut and pasted your code, putting it between the
Private Sub...... and the End Sub labels like this:
Private Sub Service_Explanation_BeforeUpdate(Cancel As Integer)
If Me.[Service-Type] = "NA" And Len(Me.[Service Explanation]) = 0 Then
MsgBox "Must enter value in Service Explanation"
Me.[Service Explanation].SetFocus ' Set the focus back to the field
Cancel = True ' wont let the user exit
End If
End Sub
I am obviously doing something wrong, though because the error message is
not appearing. I have checkled the field names and they are correct.
Should I make the DB Field in the table "Require=Yes" and "allow Zero Length
= Yes"? At the moment they are "No" and "Yes" respectively.
Sorry to be a pain.
Regards
Ray
Ofer said:
In the before update event of the form, add a validation that check the
values in the fields
If Me.[Service-Type] = "NA" And Len(Me.[Service Explanation]) = 0 Then
MsgBox "Must enter value in Service Explanation"
Me.[Service Explanation].SetFocus ' Set the focus back to the field
Cancel = True ' wont let the user exit
End If
=============
Me = current form
Service-Type, Service Explanation = need to be the name of the fields in the
form
Len = check the size of the field
--
\\// Live Long and Prosper \\//
BS"D
:
Please excuse what is probably a stupid question.
I have two fields side by side on my form "Service-Type" and "Service
Explanation".
If "Service-Type" = "NA", then I need the second field to be > space.
As an old Cobol programmer, I tried creating an Event Procedure using the If
Then Else routine but it throws out compile errors.
If someone can help, I would be extremely grateful.