SimonPGreen
IS-IT--Management
Hi all,
Don't know if I am on the right trail here but I have attempted to create some code that validates the contents of a text box @ BeforeUpdate against now() and if > msgbox advises the user that this is a future date. It takes the response via vbYesNo and if No cancels the update via DoCmd.CancelEvent, exits sub else updates with the date.
This doesn't seem have the required effect. What I want to happen is the form return completely to it's previous state i.e. not dirty, nothing in the text box etc?
Appreciate any help you can give.
Regards,
Simon
Don't know if I am on the right trail here but I have attempted to create some code that validates the contents of a text box @ BeforeUpdate against now() and if > msgbox advises the user that this is a future date. It takes the response via vbYesNo and if No cancels the update via DoCmd.CancelEvent, exits sub else updates with the date.
This doesn't seem have the required effect. What I want to happen is the form return completely to it's previous state i.e. not dirty, nothing in the text box etc?
Code:
If Me![dteCertificationDateReceived].Value > Now() Then
If msgbox("Are you sure you want to enter a date in the future?", vbYesNo) = vbNo Then
Me![dteCertificationDateReceived].Text = ""
DoCmd.CancelEvent
Exit Sub
End If
End If
Appreciate any help you can give.
Regards,
Simon