Text box validation?

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

Guest

I am trying to make a form so that when a data entry start time (text box) is
less then an End time data entry (text box) an error message pops up and does
not let the entry.
TFTH,
Tom
 
Open your table in design view.

Open the Properties box (View menu.)

Beside the Validation Rule in the Properties box, enter:
([start time] Is Null) OR ([End time] Is Null) OR ([start time] <= [End
time])

Be sure to use the table's validation rule (in the Properties box), not the
one in the lower pane of the table design window (which is the rule for one
field.)

If you want to do it in the form, use the BeforeUpdate event procedure of
the form:
Private Sub Form_BeforeUpate(Cancel As Integer)
If Me.[start time] > Me.[end time] Then
Cancel = True
Msgbox "Cannot end before it begins."
End If
End Sub
 
Back
Top