WebBrowserControl 方法 (访问)WebBrowserControl.Undo method (Access)

您可以使用 Undo 方法重置控件或窗体时其值已更改。You can use the Undo method to reset a control or form when its value has been changed.

语法Syntax

表达式撤消expression.Undo

_表达式_一个代表**WebBrowserControl** 对象的变量。expression A variable that represents a WebBrowserControl object.

备注Remarks

例如,可以使用 Undo 方法来清除对某个包含无效输入的记录的更改。For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

如果将 Undo 方法应用于窗体,对当前记录的所有更改都都将丢失。If the Undo method is applied to a form, all changes to the current record are lost. 如果将 Undo 方法应用于控件,该控件本身受到影响。If the Undo method is applied to a control, only the control itself is affected.

更新控件或窗体之前,必须应用此方法。This method must be applied before the form or control is updated. 您可以将此方法包含在窗体的 更新前 事件或在控件的 更改 事件。You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

Undo方法提供了在事件过程中使用SendKeys语句发送 Esc 键的值的替代方法。The Undo method offers an alternative to using the SendKeys statement to send the value of the Esc key in an event procedure.

示例Example

下面的示例演示如何在控件的Change事件过程中使用Undo方法, 以强制名为LastName的字段在更改时将其重置为其原始值。The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value if it changed.

Private Sub LastName_Change() 
 Me!LastName.Undo 
End Sub

下一示例使用 Undo 方法重置到窗体的所有更改,然后更新该窗体。The next example uses the Undo method to reset all changes to a form before the form is updated.

Private Sub Form_BeforeUpdate(Cancel As Integer) 
 Me.Undo 
End Sub

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.