Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date must be filled in 1

Status
Not open for further replies.

EvilTwinOfAtrus

Technical User
Dec 30, 2002
56
GB
Hi.

I have a form with a date on. The date box is 'Text196'.

What I want to do is make it so that when this text box gains focus, the user MUST enter a date. If the user doesn't then a dialogue box is displayed and the focus stays set on the 'Text196' text box. This is what I have at the moment on the 'LostFocus' event:

If Text196 = Null Then
MsgBox "Cannot leave Date Blank", vbCritical, "Please enter date!"
Text196.SetFocus
End If

This does absolutely nothing. Any ideas?

Thanks,
Karl
 
Karl,


Try something like this -

Private Sub txtDoB_LostFocus ()
Dim msg As String
If IsNull(txtDoB.Text) Then
msg = "Please enter a valid date, or leave the field empty."
msgBox msg
txtDoB.SetFocus
End If
End Sub



Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top