Required data in a form

G

Grasavong

Hello,
I created a form where certain fields have to be entered with data. If the
field is not entered a message will appear and says "This Field must be
completed." I changed the table property to that field to 'Yes' for Required
Field and in VB did a code to make the field required:

Private Sub Requestor_Name_BeforeUpdate(Cancel As Integer)
If IsNull(Me![Requestor Name]) Then
Cancel = True
MsgBox "This Field must be completed"
End If
End Sub

This works for the first form, but doesn't work for any of the forms
following. I'm a novice when it comes to VB. What do I need to change in my
code for it to reflect in the following forms?

Thanks.
 
G

Grasavong

Thank you for the reply.

There are a few things:
1. After I sent in the original question, I decided to make the required
option as a 'no' and just used the BeforeUpdate event.
2. However, while the BeforeUpdate event does tell the user that the field
must be entered, it only works if the user has originally entered data in
previously and decided to come back and delete the field. Once they delete
the field and moves on, that's when the pop up message -Field must be
entered- comes into play.
3. What validation code would I use if I needed the command to work when the
user Originally enters in new data? i.e. making a new record which requires a
blank form?

Thank you!
 

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