Save the key, or any other unique value which identifies the record, in a variable in the Current_Form event. If the user selects to not save the record, find the record based upon the variable and use docmd.delete to delete the record.
The Record is not being stored in the table until I exit the form or move to a new record. I want to allow the user to leave the form and not have the data for that record be saved to the table. I tried the Delete method but the record doesn't exist in the table yet, and if the form is just closed then the record gets saved.
Have you tried either using a me.Undo before you close the form, or a Sendkeys "{Esc}{Esc}" command to send the escape sequence to the form before closing?
The best way to do it just to create a "Cancel" button with the following code in its click event:
----------------------
if me.dirty then
me.undo
end if
docmd.close
------------------------
the me.dirty property will be true if the user has made changes to the new record. The me.undo method will undo any changes made leaving a blank new record that will not be saved at all when the form is closed. -- Herb
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.