-----Original Message-----
If you want to verify that data have been entered before a user can leave a
textbox, use the textbox's BeforeUpdate event:
Private Sub TextBoxName_BeforeUpdate(Cancel As Integer)
If Len(Me.TextBoxName & "") = 0 Then
Cancel = True
MsgBox "You must enter a value here!"
End If
End Sub
Note that the above will work only if the user actually "enters" the
textbox.
The foolproof way to do this, assuming that all the important textboxes are
bound to fields in the form's RecordSource, is to use the form's
BeforeUpdate event to do something similar:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Len(Me.TextBoxName1 & "") = 0 Then
Cancel = True
MsgBox "You must enter a value in TextBoxName1!"
Me.TextBoxName1.SetFocus
ElseIf Len(Me.TextBoxName2 & "") = 0 Then
Cancel = True
MsgBox "You must enter a value in TextBoxName2!"
Me.TextBoxName2.SetFocus
ElseIf Len(Me.TextBoxName3 & "") = 0 Then
Cancel = True
MsgBox "You must enter a value in TextBoxName3!"
Me.TextBoxName3.SetFocus
End If
End Sub