ComboBox.Undo 方法 (Access)ComboBox.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

_運算式_代表**ComboBox** 物件的變數。expression A variable that represents a ComboBox 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. 若要在表單的 BeforeUpdate 事件或控制項的 Change 事件中加入此方法。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

下列範例顯示如何您可以使用Undo方法內控制項的Change事件程序可強制名為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.