The main form's After Update event is a good place to check the various
fields to be sure they contain values. You could hide the tab control, and
make it visible if all of the required fields have been filled in. Perhaps
you could use a "Submit" button or some such thing to save the record on the
main form, and use the form's Before Update event to make the tab control
visible is the required fields have been completed.
In similar fashion you can use the Before Update event of the forms on the
tabs to be sure the required fields have been completed.
Validation code in the form's Before Update event may be something like:
If IsNull(Me.FirstName) Then
MsgBox "You forgot the first name"
Me.txtFirstName.SetFocus
ElseIf IsNull(Me.LastName) Then
MsgBox "You forgot the last name"
Me.txtLastName.SetFocus
End If
This is just one idea. There are lots of ways to go about this. For
instance, you may decide not to hide the tabs. You can still use validation
code. Or you can give the users a chance to bail:
If IsNull(Me.FirstName) Then
If MsgBox ("You forgot the first name." & _
"Click Cancel to exit without saving", vbOKCancel) = vbCancel
Me.Undo
Else
Me.txtFirstName.SetFocus
Cancel = True
End If
ElseIf IsNull(Me.LastName) Then
If MsgBox ("You forgot the first name." & _
"Click Cancel to exit without saving", vbOKCancel) = vbCancel
Me.Undo
Else
Me.txtLastName.SetFocus
Cancel = True
End If
End If
Note that if you decide to hide the tab control you will need code in the
form's Current event to hide the tab control if it is a new record, but show
it for existing records:
If Me.NewRecord Then
Me.TabControlName.Visible = False
Else
Me.TabControlName.Visible = True
End If
If a field is required, you should probably set its Required property to Yes
in table design view. The form's validation code is a convenient (and
potentially user-friendly) way to remind users about required fields that
need values, but is not a substitute for table-level requirements. You can
use table-level validation rules, but it is probably easier for the user to
respond to a form-level error message (in this case, one generated in the
Before Update event).