I'm trying to set up a validation rule for a control on my form. The control is called [evDate] which captures the date entered. If the date is later than the current date I want a simple msgbox to popup as the validation text and the user can't go beyond that field without entering a valid date. But my problem is that I need a second condition that results to a yes/no answer. If the date entered is earlier than the current date then I want a msgbox with a yes/no answer. Here's what I have on the afterUpdate event of the [evDate] control.
This code gives me the right messages but it allows the user to continue with not putting in a date that meets the requirements. Can someone help me with this?
Code:
If [evDate] > Date Then
MsgBox "can't be later than today."
DoEvents
evDate.SetFocus
ElseIf [evDate] < Date Then
results = MsgBox("you entered a date earlier than today. do you want to continue with the entry",vbYesNo)
If results = vbYes then
Else
DoEvents
evDate.SetFocus
Endif
End If
This code gives me the right messages but it allows the user to continue with not putting in a date that meets the requirements. Can someone help me with this?