need help with textbox validation rule

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

Guest

Hi,
How do I use validate rule in a textbox, say if I want to make sure the
data enter to textbox1 is a date?

Thanks,
 
Hi,
How do I use validate rule in a textbox, say if I want to make sure
the data enter to textbox1 is a date?

Thanks,

Hi Jeff,

Validation can be as complex as you desire. It is generally done
in the BeforeUpdate event and could look something like:

--- Warning Air Code ---

Private Sub txtbox1_BeforeUpdate(Cancel As Integer)

If Not IsDate(Me.txtbox1) Then
MsgBox "Must have a Date in this box!"
Me.Undo ' Clear the textbox
Cancel = True ' Hold the cursor in this textbox
End If

End Sub

Post back if you need additional details.

HTH
 
Back
Top