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 Last Action Only

Status
Not open for further replies.

Muzzy

Programmer
Dec 14, 2001
68
GB
Hello All,

Please help. I have a command button on a form that will undo all actions, at once, up until the last save was made. However I only want to undo the last action made with the ability to keep undoing the last action until you reach the point of the previous save, exactly like the undo button works in word.

Cheers

Muzzy
 
Good idea but that isn't built into Access. You could build an application to accomplish this but it would not be a simple task.

Using an array to keep track of the various controls and their sequencing write the control name to the array. An undo button would read the name of the last control updated and replace the .Value with the .OldValue then remove the control name from the bottom of the (LIFO) array. This would work but only on a control by control basis.
-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
I might add, it get's REALLY tricky when you try to implement that on datasheets.

That being said, a more generic, but more expensive to implement solution, is to generate an audit trail of ALL actions.

The audit trail contains ActionType, TableName, ValueList
e.g.
Update Field1, 1, Field2, "blah", Field3, 01/15/2003
Add Field1, 1, Field2, "blah", Field3, 01/15/2003
Delete Field1, 1, Field2, "blah", Field3, 01/15/2003

you have to trap AfterUpdate, and BeforeDelete events.
Use the form recordsetclone edit mode to determine if an update or an add.

Then, to roll back changes, you seek using the primary key of the table and the stored field information, and perform the appropriate action.

BTW, you may then want to implement a redo.

So, you would have to add a field to the above audit trail, indicating if each entry is an undo or a redo.

This gives you a 'persistent' undo capability, and a convenient audit trail for monitoring user events.

Of course, it wastes a tremendous amount of space; so you may want to clear the table after each session.

You have to be careful to undo actions in the opposite order of how they were done.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top