Is there a simple way to make sure all fields on a form are filled before the data is saved to the table? I looked into using thew IF is Null Then but for 30 fields that is alot of code. Does anyone know a easier way?
You must use the forms BeforeUpdate event to perform your validation code.
You can simply use an IF as suggest but you also have to test for empty strings.
Code:
If IsNull(MyField) or MyField = "" Then
The below might be more efficient...
Code:
Key "Required" in the Tag property of the form object.
Dim ctl As Control
For Each ctl In Me
If ctl.Tag = "Required" Then
If IsNull(ctl) Or ctl = "" Then
MsgBox "You must complete all required fields to continue", vbCritical, "Required Field"
ctl.SetFocus
Exit Sub
End If
End If
Next
Set ctl = Nothing