Full Version: Save Button on form
UtterAccess Forums > Microsoft® Access > Access Forms
blun
Hi there,
My users are editing data from a table via a form. At the moment their changes are made 'live' - if they close the form the changes are saved.
How do I make sure that any changes are not saved until a save button is pressed? I'd also like a cancel button that does not save changes to the form.
Thanks!
petite39
Set the property for the close button on your form to no.
When create an undo command button on your form from the command button wizardv on the tool bar.
xteam
Try this:
on beforeUpdate event for your form put something like:
If MsgBox("Do you want to save changes?", vbYesNo) = vbNo Then
DoCmd.RunCommand acCmdUndo
End If
blun
xteam - thats very handy! Not exactly what I'm trying to do on this form but useful for some other forms I need to do.
That I need on this form is an undo button (done) a "close and save" button and a "cancel and don't save" button.
Thanks!
xteam
On Close and Save you'll need to have :
DoCmd.RunCommand acCmdSave
and here the command to close the form
ancel and don't save:
DoCmd.RunCommand acCmdUndo
and here the command to close the form
blun
Almost there now!
The save and close works.
The cancel and dont save works if the data has changed - but if I make no changes and just click cancel I get:
"The command or action 'undo' is not available now"
Is there a way to prevent that error?
xteam
Cancel and don't save:
If Me.Dirty Then
DoCmd.RunCommand acCmdUndo
Endif
and here the command to close the form
blun
Thats exactly what I was after.
Thank you!
xteam
You're welcome frown.gif !
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.