Code for making field required

pablavo

Registered User.
Local time
Today, 11:09
Joined
Jun 28, 2007
Messages
189
Hi
I know this one is a simple code issue! does anyone know what the code is for making a control on a form required so that the user has to enter info into it before they can exit?

Cheers
 
The simplest solution is to make the field required at the table level.
 
Thanks for the reply Pbaldy!

I wasn't actually asking for the easiest solution on how to make a field required! What I was asking was if anyone knew what the VBA was to make a field required!

Thanks anyway:)

Does anyone know?
cheers
 
In the before_update event of the form you could use something like:

if Me.ControlName.Value & "" = "" Then
Cancel =True
Msgbox "Fill it in dummy",vbinformation
End if
Or, something like the following placed in the click event of your form's 'exit' button:

if Me.ControlName.Value & "" = "" Then
Msgbox "Fill it in dummy",vbinformation
Else
Docmd.Close
End if

You may need something similar in any record navigation buttons on the form too.
 

Users who are viewing this thread

Back
Top Bottom