validation rule

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...
 
R

Rick B

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 "
 
G

Guest

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
 
G

Guest

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.
 
T

tina

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
 

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