Cancel Delete

kbreiss

Registered User.
Local time
Today, 19:26
Joined
Oct 1, 2002
Messages
228
On my delete button of my form I was wondering if there was a way for users to cancel the delete macro if they accidentaly hit the delete button.

Thanks in advance.

Kacy
________
Medical marijuana
 
Last edited:
Hi there,

I don't actually use macros, I tend to use code. Here's an example of code that I use in my delete button:

Private Sub cmdDelete_Click()


' Ask the user to confirm they want to delete the record

DoCmd.SetWarnings False
JobNo = DLookup("JobNumber", "tblJobList", "[JobNoID] = Forms!frmAmendTimesheet!frmAmendTimesheetSubform.Form!cboJobNumber")

strMessage = "You are about to delete the record of hours for Job Number " & JobNo & vbCr & vbCr
strMessage = strMessage & "WARNING : You will not be able to undo this operation. If you wish to "
strMessage = strMessage & "proceed then click 'Yes' otherwise click 'No'"
style = vbCritical + vbYesNo
strTitle = "Delete Record?"

Response = MsgBox(strMessage, style, strTitle)

If Response = vbYes Then 'Delete record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Else
Exit Sub
End If



End Sub

This may give you some ideas

HTH
Rob
 
Robert Dunstan said:
Code:
        DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
        DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

That part is redundant now; use:

DoCmd.RunCommand acCmdDeleteRecord
 
Thank you guys....can't wait to try this when I get back to work on Monday.

Thanks Again!

Kacy
________
Vaaapp Vaporizer
 
Last edited:

Users who are viewing this thread

Back
Top Bottom