Close Form With No Update

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have searched high and low but I can't find a way exit a form without saving the record associated with that form. The only way out is by using DoCmd.Close, but if I set the "Save" parameter of of DoCmd.Close to "AcSaveNo", it still saves the record. I can't see that it makes any difference

Can anybody enlighten me? Thanks.
 
Michael Ryle said:
I have searched high and low but I can't find a way exit a form without
saving the record associated with that form. The only way out is by using
DoCmd.Close, but if I set the "Save" parameter of of DoCmd.Close to
"AcSaveNo", it still saves the record. I can't see that it makes any
difference.
Can anybody enlighten me? Thanks.

acSaveNo refers to design changes of the form, not changes to data. You
would have to put code in the Form's BeforeUpdate like...

Cancel = True
Me.Undo

....to cancel the update and rollback any changes. Won't work if you have a
subform though.

You know you can just press <Escape> twice to undo unsaved edits right?
 
The acSaveNo is to not save changes to the form itself, such as if you had
the form open in design mode and manipulated through code while in that
mode. It doesn't refer to the record. To close the form without saving the
record, you need to undo the changes to the record. To do this, press Esc
twice (the first press undoes the last field change). To do this in code,
the command is Me.Undo.

--
Wayne Morgan
Microsoft Access MVP


Michael Ryle said:
I have searched high and low but I can't find a way exit a form without
saving the record associated with that form. The only way out is by using
DoCmd.Close, but if I set the "Save" parameter of of DoCmd.Close to
"AcSaveNo", it still saves the record. I can't see that it makes any
difference.
 
Thanks Rick and Wayne. "Me.Undo" followed by "DoCmd.Close" works, though you'd think there would be a more straightforward, more intuitive way of accomplishing the task. After all, it's pretty much standard UI practice for dialogs that change something to provide a "CANCEL" button that cancels changes before exiting the dialog.
 
Intuitive is for the user, not the developer, at least it feels that way
sometimes. <g> :-)

--
Wayne Morgan
Microsoft Access MVP


Michael Ryle said:
Thanks Rick and Wayne. "Me.Undo" followed by "DoCmd.Close" works, though
you'd think there would be a more straightforward, more intuitive way of
accomplishing the task. After all, it's pretty much standard UI practice
for dialogs that change something to provide a "CANCEL" button that cancels
changes before exiting the dialog.
 
Back
Top