Form.Undo event (Access)
Occurs when the user undoes a change.
expression A variable that represents a Form object.
|Cancel||Required||Integer||Set this argument to True to cancel the undo operation and leave the control or form in its edited state.|
The Undo event for controls occurs whenever the user returns a control to its original state by choosing the Undo Field/Record button on the command bar, choosing the Undo button, pressing the Esc key, or calling the Undo method of the specified control. The control needs to have focus in all three cases. The event does not occur if the user chooses the Undo Typing button on the command bar.
The Undo event for forms occurs whenever the user returns a form to its original state by choosing the Undo button, pressing the Esc key, or calling the Undo method of the specified form.
The following example demonstrates the syntax for a subroutine that traps the Undo event for a form.
Private Sub Form_Undo(Cancel As Integer) Dim intResponse As Integer Dim strPrompt As String strPrompt = "Cancel the undo operation?" intResponse = MsgBox(strPrompt, vbYesNo) If intResponse = vbYes Then Cancel = True Else Cancel = False End If End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.