DoCmd.Close

G

Guest

I would like to use the 'Close' command so that it does NOT save any data
entered so far on the form.

I have frequently specified 'DoCmd.Close,,Save No', or sometime
'Prompt', but to no avail, the data on the form is SAVED - always SAVED.

I must be doing something wrong.
 
A

Allen Browne

The acSaveNo option of the Close method only affects whether design changes
are saved. It does not affect the saving of the record at all.

When you close a bound form that the user is editing, this sequence of
events is triggered:
1. Any events for the control.
2. The form's BeforeUpdate event, AfterUpdate, and AfterInsert.
3. The form's Unload event.
4. The form's Close event.

The last chance you have to prevent the record being saved is
Form_BeforeUpdate. By the time Form_Unload or Form_Close fire, the record is
already saved.

Therefore, if you want to prevent the record being saved, you must cancel
the form's BeforeUpdate event. That will work regardless of how the save is
taking place.
 
G

Guest

Thank you Allen for your clear response - it is something that I did not
understand before.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top