Custom message on delete

  • Thread starter Thread starter DD
  • Start date Start date
D

DD

I have a command button on a form to delete and I would
like to add a custom delete confirmation (as opposed to
the "you are about to delete..." message. I need to know
the syntax to do that along with where it will be placed
in the code. Thanks in advance. Happy weekend all.

Here is my code:

Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

Exit_cmdDelete_Click:
Exit Sub

Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click

End Sub
 
For you form there is an event that fires when a record is deleted. "On
Delete" in the Form Properties under events.

Put a MSGBox in that even procedure...

Private Sub Form_Delete(Cancel As Integer)
dim myresp as integer
myresp = MSGBOX("Are you sure you want to delete the current Record?",
vbyesno, "Deletion Confirmation")
if myresp = vbno then
cancel = true
endif
End Sub


HTH
Kat
 
Back
Top