required fields on forms

D

DJ Finnegan

I have a form that has a yes/no check box for cetain fields. If this box is
yes I want certain other fields required input. Is this possible?
Any help would be appreciated, this is getting way over my head.
 
J

John W. Vinson

I have a form that has a yes/no check box for cetain fields. If this box is
yes I want certain other fields required input. Is this possible?
Any help would be appreciated, this is getting way over my head.

You can do this kind of checking in the Form's BeforeUpdate event. Click the
.... icon by that event property and choose Code Builder; edit the code to
something like

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me!checkboxcontrol Then
If Me!txtThis & "" = "" Then
MsgBox "If <checkbox> is checked you must fill in <textbox>", vbOKOnly
Me!txtThis.SetFocus
End If
End If
End Sub
 
D

DJ Finnegan

THANKS!!!!

John W. Vinson said:
You can do this kind of checking in the Form's BeforeUpdate event. Click the
.... icon by that event property and choose Code Builder; edit the code to
something like

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me!checkboxcontrol Then
If Me!txtThis & "" = "" Then
MsgBox "If <checkbox> is checked you must fill in <textbox>", vbOKOnly
Me!txtThis.SetFocus
End If
End If
End Sub
 
Top