Table of contents

通过使用自定义条件来取消删除记录Cancel the Deletion of a Record by Using Custom Criteria

office 365 dev account|上次更新日期: 2017/9/25
1 参与者

以下示例说明如何使用窗体删除事件以防止对记录的删除根据自定义条件。在此示例中,如果 DataRequired 字段的值为是取消删除事件。The following example illutrates how to use a form's Delete event to prevent the deletion of a record based on custom criteria. In this example, the Delete event is canceled if the value of the DataRequired field is Yes.

Private Sub Form_Delete(Cancel As Integer) 

   ' Check the value of the DataRequired field. 
    If Me.DataRequired = "Yes" Then 

      ' Cancel the record deletion. 
      Cancel = True 

      ' Notify the user. 
       MsgBox "Cannot Delete the Record." 
    End If 
End Sub
© 2018 Microsoft