I have a 'delete' (maco) button on a form to delete the current record and then do the same in other tables. It works just fine but I want to add a warning message to it with the option to cancel deletion. Will appreciate some guidance here Thanks
You need to interrupt the delete action in the Before Delete Confirm and Delete events of the Form. I'm guessing the form is bound.
Your code could look like this:
Code:
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
Response = acDataErrContinue
End Sub
Private Sub Form_Delete(Cancel As Integer)
If MsgBox("Do you want to delete?", vbYesNo + vbExclamation, "Delete confirmation!") = vbNo Then
Cancel = True
End If
End Sub
It's a 'control' record from a table which accumulates related information from various other tables sharing a common reference number and each having a one-to-one relationship. Viewed together this 'accumulated' information describes the entity referred to by the reference number.
I can't put all the fields in one table as it would exceed the 255 field limitation by at least double.
Hence, when (if) I delete the control record I remove the related record from each of the data tables as well.