Full Version: Canceling without saving current record
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
smithochris
Hi, I have a form with a cancel button on it. If the user hits the cancel button, I want it to close the form and not add whatever the user has chosen on the form to the table it is connected with. I only have Docmd.close as the code for this button. I was trying stuff like:

DoCmd.close(,,acSaveNo) - I'm not sure what this means, but I saw it as an option. But it gives me an error anyway. It says that it is expecting an "=" somewhere. This probably isn't even the right thing to use.

If I select stuff on the form and even hit the "X" in the top right of the form, it still adds that record to the table. I don't understand why - this is why I was trying to add a cancel button in the first place. Thank you for your help
freakazeud
Read this:

Cancel
datAdrenaline
Add a command button labeled 'Cancel' an create the OnClick event with the following code.

CODE
Public Sub btnCancel()
    Me.Undo   'Undoes the changes on the form
End Sub
smithochris
Thanks, the me.undo seems to work great.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.