cancle button macro

  • Thread starter Thread starter kgt169
  • Start date Start date
K

kgt169

Guest
Hello,
Ive been learning to use access so far from the help file alone, I have my database all set up, but I need to add cancle without saving buttons to my forms I followed the instructions exactly (in the help files) but the button closes the form and saves the changes to the table. I Did set the macro to no save but it doesnt work. Am i missing something?
Thanks for any help in advance
 
The Save option that you are setting for the Close action is checking to see if the layout of the form has been changed, not if the record has been changed.

A quick solution is to add an extra line to your cancel macro before the Close action as follows:

Action: RunCommand
Command: Undo

This command undoes any changes the user has made to the current record.

A couple of things to keep in mind is that Access automatically saves changes made to a record whenever you close a form, move from one record to another within a form or choose save record from the Records menu.

If you need any further information, please let me know.

Cheers,
SteveA
 
I have a button like this, but when I click "Cancel", I get an error message.

The command or action 'Undo' isn't available now.
I'm pretty sure this is because nothing has been changed, so nothing can be undone. Is there a condition I could add before the "Runcommand" condition so that it only runs "Undo" if something has been changed?
 
Hello,
Ive been learning to use access so far from the help file alone, I have my database all set up, but I need to add cancle without saving buttons to my forms I followed the instructions exactly (in the help files) but the button closes the form and saves the changes to the table. I Did set the macro to no save but it doesnt work. Am i missing something?
Thanks for any help in advance


Just create the button....then with the wizard, choose "Record Operations", then choose "Undo Record".

Keep in mind, this button only applies to the current record. Like Steve said, once you or your users advance to the next record or close the form, the record is automatically saved. Hope this helps.
 
You can test first if there is anything to undo by using
Code:
If Me.Dirty Then
   Me.Undo
End If
 
I have a button like this, but when I click "Cancel", I get an error message.

I'm pretty sure this is because nothing has been changed, so nothing can be undone. Is there a condition I could add before the "Runcommand" condition so that it only runs "Undo" if something has been changed?

I was having the same problem as yours ..just type a condition >> [Forms]![Your Form Name].[Dirty]=-1...besides the RunCommand action and it will quit without this error message...Hope it helps :)
 
*chuckle* Thanks! Actually, I've eeeeeeeever so slowly been learning SQL, so I solved this problem a while ago. ^_^
 

Users who are viewing this thread

Back
Top Bottom