Escape or Cancel code for command button

lmcc007

Registered User.
Local time
Today, 01:10
Joined
Nov 10, 2007
Messages
635
I created a dialog form with two command buttons: Ok and Cancel. When I click OK, it closes the dialog box. When I click Cancel, it does nothing. I want the Cancel button to work like the Esc button—that is, undo any changes made or close the form without saving the changes.

On Click Event I entered: DoCmd.CancelEvent. This code is not doing anything.

What’s the correct way to do this?
 
In the button's Click event, try the following code:
Code:
Me.Undo
DoCmd.Close acForm, Me.Name, acSaveNo
 
I think you will also want

Me.Undo
 
BM, did you add that later or am I going blind? :eek:
 
Then I'm sorry for stepping on you there. All my poor old eyes saw was the DoCmd.Close line.
 

Users who are viewing this thread

Back
Top Bottom