make a command button not execute when form contains a null value

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

Guest

I have a form that opens when someone closes the database, and I would like
to make the command button at the bottom work only if the form does not have
any null values in all fields except for the field named "Inprovements" How
do I do this?
*NOTE* I am a Newbie to access...
 
On the OnClick event of the command button put code something like the
following:

'Test to see if field 1 is null
If IsNull(Me.Field1) Then
'If it is tell the user what the problem is
MsgBox "Field1 is a required field."
'Put the focus on the field that is null to help the user
Me.Field1.SetFocus
'End the procedure so the other form doesn't open
End
End If

'Test to see if field 2 is null
If IsNull(Me.Field2) Then
'If it is tell the user what the problem is
MsgBox "Field2 is a required field."
'Put the focus on the field that is null to help the user
Me.Field2.SetFocus
'End the procedure so the other form doesn't opern
End
End If

'If neither of your if statements is true then open your form

DoCmd.OpenForm....
 

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

Back
Top