Mandatory Fields in Forms??

A

Al Gavenas

We have database which uses several forms for data entry,
and feeds a table.Each form has unique data that is
required. My question: Is it possible to make a data field
in a form mandatory information? Our forms are set up to
screen the data before allowing the information to be
entered in the table. Unfortunately if our data entry
clerk tabs over a particular field, no data is entered and
the information never entered or screened. Is it possible
to make a data field in a particular form mandatory
information? I know it can be done in the table, but we
are trying to use the form for this screening process.
 
A

Al Gavenas

Do you have a brief example of how I could set this up?
Sounds like this would work for me!!

Thanks Al
 
J

John Vinson

Is it possible
to make a data field in a particular form mandatory
information? I know it can be done in the table, but we
are trying to use the form for this screening process.

You'll need a little bit of VBA code to do this. Open the Form in
design mode and view its Properties; on the Events tab select the
BeforeUpdate event and click the ... icon. Choose the Code Builder
option; Access will give you the Sub and End Sub lines. Edit to
something like:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me!txtMyTextbox) Then
MsgBox "Please fill in MyTextbox before saving", vbOKOnly
Me!txtMyTextbox.SetFocus
Cancel = True
End If
End Sub

This will prompt the user, put the cursor into the textbox, and cancel
actually saving the record until they enter something.
 

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

Similar Threads


Top