Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undo is isn't available

Status
Not open for further replies.

Vcscwi

Programmer
Jan 15, 2004
57
US
I have a form with a save and cancel button.

My cancel button has...

DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close , , acSaveNo

but if the user has not made any changes, VBA creates an error stating "UNDO is not available at this time".

Is there a way to run a check to avoid this error?

Thanks for the suggestions!
 
Can you do an on error routine now I am no expert but it might go something like this.

On error go to handleundo





handleundo:
If (err= undoerror) then
resume next'

You would need the message number of the error to define it as a variable.

Cretin
 
try
Code:
if Me.Dirty Then
   DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
end if
DoCmd.Close , , acSaveNo
Me.Dirty returns true if the record has been changed but not yet saved.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top