Custom message on delete

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
 
K

Katrina

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top