Hi Have a form where dates will be entered, and I am trying to use some code to prevent the user from entering in the dates wrong. i.e. having the start date greater than the end date.
I have used the code below which works fine, but it can be easy for the user to press the tab key twice after the error message appears and move on without ever changing the date.
Is it possible to not allow the user to move on until the end date has been corrected.
Private Sub DateFor_Enter()
If IsNull([DateBooked]) Or IsNull([DateFor]) Then
MsgBox "You must enter The Dates."
DoCmd.GoToControl "DateFor"
Else
If [DateBooked] > [DateFor] Then
MsgBox "The Date At time of booking must be greater than Date Booked for."
DoCmd.GoToControl "DateFor"
Else
Me.Visible = False
End If
End If
End Sub
Or is there something that I can Enter as an expression in the validation Rule Section of the Table design.
Hope someone can shed some light on the matter
Kindest Regards
Cillies
I have used the code below which works fine, but it can be easy for the user to press the tab key twice after the error message appears and move on without ever changing the date.
Is it possible to not allow the user to move on until the end date has been corrected.
Private Sub DateFor_Enter()
If IsNull([DateBooked]) Or IsNull([DateFor]) Then
MsgBox "You must enter The Dates."
DoCmd.GoToControl "DateFor"
Else
If [DateBooked] > [DateFor] Then
MsgBox "The Date At time of booking must be greater than Date Booked for."
DoCmd.GoToControl "DateFor"
Else
Me.Visible = False
End If
End If
End Sub
Or is there something that I can Enter as an expression in the validation Rule Section of the Table design.
Hope someone can shed some light on the matter
Kindest Regards
Cillies