There are multiple ways to do this, as Paul indicated, but I generally use the following:
Set the Tag Property, for all Controls that you want to have checked, to Required (no Quotes, please.)
To set the Tag Property for multiple Controls, in one fell swoop:
- Go into Form Design View
- Holding down <Shift> and Left clicking on each Control in turn, to select it.
- Go to Properties – Other and enter your value (Required) in the Tag Property; it's the last Property under Other.
Now, add this code behind your Form:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "Required" Then
If Nz(ctl,"") ="" Then
Cancel = True
Msgbox ctl.Name & " is a Required Field and Must Have Data Entered"
ctl.SetFocus
Exit Sub
End If
End If
Next
End Sub
You should now be set!
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007