Don't Save Changes

karcher

New member
Local time
Today, 18:57
Joined
Jul 27, 2001
Messages
5
I'm having problems trying to create a piece of code that will close a form in either of two ways depending on what the user does.

If the user changes the contents of any of the textboxes, I want the close button to prompt them to save the record.

If they choose "yes", then it should save the record but if the choose "No" it should close the form without saving any changes.

I can get the saving part to work but I can't find a way to prevent Access from saving changes to the record.

Any help is greatly appreciated!
 
I think you can get somewhere by looking up the DoCmd.Undo action in the Help Files. This is how you choose to not save a record.

(At least, it is how I do it in MY database.)
 
The problem is that by the time the Form Close event is fired, the record has already been saved. You need to put the save prompt in the Form's BeforeUpdate event. If they say not to save, then you need to cancel the save event with the following statement:
Cancel = True
 

Users who are viewing this thread

Back
Top Bottom