Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cancel behavior

Status
Not open for further replies.

SimonPGreen

IS-IT--Management
Mar 8, 2004
116
GB
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?

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
 
how are ya SimonPGreen . . .

Try [blue]Me.Undo[/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
The Aceman strikes again.

Almost embarressed it was so easy.

Thanks again.

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top