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

W

Walter Mills

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

Terri

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