两个步骤:先设Cancel为True,然后调用该控件的Undo方法。
Private Sub ProductName_BeforeUpdate(Cancel As Integer) If(Not IsNull(DLookup("[ProductName]",_ "Products","[ProductName] ='" _ & Me!ProductName & "'"))) Then MsgBox "Product has already been entered in the database." Cancel = True Me!ProductName.Undo End If End Sub
示例来自微软VB帮助