validation rule

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a validation rule so that one of the fields in my form
can't be left blank. I tried using, "Is not null" and "not null" and " <>0"
and "Is null" in the validation rule sections of the table and/or the form
controls but no combination has prompted the error messages I have typed into
the validation text box. I can't figure out what I am doing wrong. Can anyone
help me?

Thanks...
 
What type of field is it?



--
Rick B



Feeling unvalidated said:
I am trying to create a validation rule so that one of the fields in my form
can't be left blank. I tried using, "Is not null" and "not null" and "
 
Put this in the Before Update event of the text box you want to validate:

If IsNull(Me.MyTextBoxNameHere) Or Me.MyTextBoxNameHere = "" Then
MsgBox "Data is Required"
Cancel = True
End If
 
I don't think it's a field, Rick. I believe it is a text box. Note:
"fields in my form"
I wish people would use the correct terminology when they post.
 
if you want to ensure that there is data in that field in both new records
and existing records, try adding the following to the form's BeforeUpdate
event procedure, as

Private Sub Form_BeforeUpdate(Cancel As Integer)

If IsNull(Me!MyControlName) Then
Cancel = True
Msgbox "Enter the required data."
Me!MyControlName.SetFocus
End If

End Sub

substitute the correct name of the control on the form.

hth
 
Back
Top