When using this event you will lose access to your data.
Access Programming Tip
Sometimes you may need to confirm deletion of a record with a user before allowing them to delete the record. The BeforeDelConfirm event will allow you to cancel the deletion if necessary. But one problem with this event is the lack of access to your data, therefore using form data is out of the question. To avoid the situation, use the Delete event on the form.
Delete Event Does Allow Access To Data
I had built a check register program for a client and one of the requirements was to prevent checks that were voided from being deleted. My program would look at the check number and if the word "Void" was in it, then prevent deletion of the database record. I used the Delete event and would set Cancel = True. Below is the code fragment I used:
If Me.CheckNumber = "Void" Then
Cancel = True
Me.Undo
MsgBox "Voided checks cannot be modified.", vbInformation, "Can't Change Check"
Exit Sub
End If |