check to see if undo is available

bunji

Registered User.
Local time
Today, 07:45
Joined
Apr 26, 2005
Messages
124
I would like to be able to check to see if undo is available.

ie. i have a button thats called 'Cancel' When clicked it undo's changed and then closes the form, but if there are aren't any changes to undo it flags up an error saying not available.

I would still like it to close the form even if there are no changes to undo.

So check to see if the undo is available then undo and close if not then just close the form.
 
If you place the following around the undo command it will ignore the error 'Undo not availble'

On Error GoTo Err_Undo_Record_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70



Exit_Undo_Record_Click:
Exit Sub

Err_Undo_Record_Click:
'2046 means undo not available’
If Err.Number = 2046 Then
Resume Next
Else
MsgBox Err.Number & vbCrLf & Err.Description
Resume Exit_Undo_Record_Click
End If
 
DoMenuItem has been obsolete for years and shouldn't be used anymore
 
Behind you command button (Cancel) put this;

Code:
Me.Undo
 

Users who are viewing this thread

Back
Top Bottom