ACC: How to Create an Undo Record Button on a FormID: Q101079
|
Moderate: Requires basic macro, coding, and interoperability skills.
Microsoft Access versions 1.x and 2.0 do not have a built in way to undo
changes made to the current record. This article demonstrates a sample
user-defined Access Basic function that you can use to undo changes made to
the current record.
NOTE: In Microsoft Access for Windows 95 version 7.0, you can create a
button to undo the current record by using the Command Button Wizard. For
more information about the undo record command button, search for "Undoes,"
and then "Create Command Button That Adds, Deletes, Duplicates, Prints,
Saves, And Undoes Current Record" using the Microsoft Access for Windows 95
Help Index.
NOTE: This article explains a technique demonstrated in the sample
files, FrmSampl.exe (for Microsoft Access for Windows 95 version 7.0)
and FrmSmp97.exe (for Microsoft Access 97). For information about how
to obtain these sample files, please see the following articles in the
Microsoft Knowledge Base:
Q150895 ACC95: Microsoft Access Sample Forms Available on MSL
Q175066 ACC97: Microsoft Access 97 Sample Forms Available on MSL
To undo the changes to the current record, you can use the DoMenuItem
macro action to choose Undo Current Record from the Edit menu.
However, this menu item is available only when there are changes to
undo. Attempting to use the DoMenuItem action when no changes have
been made to the current record causes the following error message to
appear:
Command not available: UndoCurrentRecord
Option Explicit
Function UndoRecord ()
On Error Resume Next
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_UNDOFIELD
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_UNDO
End Function
For more information about the command DoMenuItem, search for "DoMenuItem" using the Microsoft Access Help menu.
Keywords : kbusage FmsEvnt
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: March 25, 1999