Undo changes IF changes made.

G

Guest

I have a form where new records can be created and at the bottom of the form
I have two buttons, one to save and one to return to the main form.
The save button is appending from a temp table and then deleting the temp
table.
The return button is undoing any changes and returning to the main screen.
The problem: If no changes were made on the form this button gives an error
saying "The command or action 'Undo' isn't available now."
Is there an 'If' statement that I can put in that says If changes were made
on this form then run undo?
Thank you
Here is my code at this point for this button:

Private Sub Return_to_Admin_Functions_Click()
On Error GoTo Err_Return_to_Admin_Functions_Click

'Undo new information
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

Dim stDocName As String

stDocName = "Enter Fine to Admin"
DoCmd.RunMacro stDocName

Exit_Return_to_Admin_Functions_Click:
Exit Sub

Err_Return_to_Admin_Functions_Click:
MsgBox Err.Description
Resume Exit_Return_to_Admin_Functions_Click

End Sub
 
A

Allen Browne

To undo only if there are uncommited edits in progress:

If Me.Dirty Then Me.Undo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Filtered records 3
close a form without saveing 1
undo changes 2
Lost Focus of Form 1
Undo button fails 9
do not save data on subForm 5
Stamping a field in a table from a form 7
why do I get an error 1

Top