End date less (earlier) than Start date

batowiise

Registered User.
Local time
Today, 10:42
Joined
Nov 9, 2010
Messages
17
Hi Everyone,

I have two unbound text fields namely txtStartDate and txtEndDate on a form. I want to verify that txtEndDate is not less (earlier) than txtStartDate and when this condition is met, a message pops up notifying the user.

I have tried using the following code but am not getting the desired result.

txtEndDate.SetFocus
If txtEndDate.Text < txtStartDate then
Msg "Please rectify Date, End Date earlier than Start Date"
txtEndDate.SetFocus
exit sub
End If

Your help and support is much needed and welcome.

Thanks in advance

Batowiise
 
I tweaked your code slightly and created an [Event Procedure] on the txtEndDate field and it worked.

Code:
Private Sub txtEndDate_LostFocus()
    If Me.txtEndDate < Me.txtStartDate Then
        MsgBox "Please rectify Date, End Date earlier than Start Date"
        Me.txtStartDate.SetFocus
    End If
 
Last edited:

Users who are viewing this thread

Back
Top Bottom