UNDO command problem

russi

Registered User.
Local time
Today, 02:02
Joined
Jul 18, 2000
Messages
385
Hi.

I needed a button on forms that would allow a user to cancel changes they made, without saving them upon exiting the form.

Using UNDO on a button that will then close the form works great EXCEPT IF the person has not changed anything. Then they get an error message tied to 'nothing to undo'.

How to accomplish both situations?
 
Trap the error... If if the error happens, just have your program resume next or go to an Exit Event. Hope this helps.

Doug
 
Thanks but I have no idea as to how do what you suggest.
Could (would) you provide sample code or steps to do this?
Thanks.

Russ
 
Alright, at the top of your code for the undo button, put:

on error goto Undo_Click_Error

then at the bottom of your code, right above the end sub command, put the following code

exit sub

Undo_Click_Error:
if err.number = xxx then
resume next
else
msgbox err.number & ": " & err.description
end if

were xxx is the error number that pops up when the record wasn't changed.

You can also use the dirty property to tell if the record was changed. In the Click Event of the button, put the following code...

if me.dirty then
me.undo
end if

That is all you would need. The dirty property returns true if a record has been changed or false if it has not changed. Hope one of these solutions helps you.

Doug
 
Thanks. Sorry if I was a 'dunce'.

Russ
 

Users who are viewing this thread

Back
Top Bottom