Required fields before saving

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

Guest

I have a form that uses a check box to activate certain fields for data entry.

I would like to know how to make sure that [region], [station] and [shift]
have been entered if checkbox [als] has been marked.

I was thinking about using the tab order and the 'on exit' event, but I
think that it might be cleaner to validate when the user tries to save the
entry.

Thanks in advance
 
Hi,
use the before update event. You can code this individually for each of
these controls or you can use the tag property of them and make it easy:

Dim ctl As Object

If Me.YourCheck = True Then
For Each ctl In Me.Controls

If (ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox) And ctl.Tag
= "Validate" Then
If Nz(ctl, "") = "" Then
MsgBox("You have to fill out all the controls first!")
Cancel = True
End If
Exit For
End If
End If
Next ctl

Now in each control you want to validate put "Validate" in their tag property!
Untested, but should give you the idea.
HTH
Good luck
 
Back
Top