Form.OnUndo property (Access)

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Undo event occurs. Read/write.

Syntax

expression.OnUndo

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action that Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

Valid values for this property are:

  • macroname, where macroname is the name of a macro.

  • [Event Procedure], which indicates the event procedure associated with the Undo event for the specified object.

  • =functionname(), where functionname is the name of a user-defined function.

Example

The following example specifies that when the Undo event occurs on the first form of the current project, the associated event procedure should run.

Forms(0).OnUndo = "[Event Procedure]"

The following example specifies that when the Undo event occurs in any text box on the first form of the current project, the associated event procedure should run.

Dim ctlLoop As Control 
 
For Each ctlLoop In Forms(0).Controls 
 If ctlLoop.Type = acTextBox Then 
 ctlLoop.OnUndo = "[Event Procedure]" 
 End If 
Next ctlLoop 

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.