Code not working...Why?

ian_ok

Registered User.
Local time
Today, 10:57
Joined
May 1, 2001
Messages
90
What is wrong with this code, is won't verify the date entered correctly?

txtCheckInDate is an unbound field
Ian

Private Sub txtCheckInDate_LostFocus()
'Validate data entered'
If txtCheckInDate.Value < Date Then
MsgBox "The arrival date must be today or later!"
txtCheckInDate = Date
txtCheckOutDate.SetFocus
txtCheckInDate.SetFocus
Else
If txtCheckInDate.Value > Date + 365 Then
MsgBox "Bookings are only taken for 1 year or less"
txtCheckInDate = Date
txtCheckOutDate.SetFocus
txtCheckInDate.SetFocus
Else
If IsNull(txtCheckInDate) Then
MsgBox "You must enter a date"
txtCheckOutDate.SetFocus
txtCheckInDate = Date
txtCheckInDate.SetFocus
Else
txtCheckOutDate.SetFocus
Exit Sub
End If
End If
End If
End Sub
 
Try one of these:

If txtCheckInDate > DateAdd("yyyy", 1, Date) Then

If DateValue(txtCheckInDate) > DateAdd("yyyy", 1, Date) Then
 

Users who are viewing this thread

Back
Top Bottom