No Delete confirmation

pepegot1

Registered User.
Local time
Today, 08:15
Joined
Feb 20, 2006
Messages
25
The prgram works well, except in one situation. When I delete a record, using the delete form, I do not get any confirmation. The record is deleted and the next record is displayed. This is not a good thing. How can I ensure delete confirmation? Here is the wizard button code: Looks like this canned stuff is not too good.

Private Sub delete_Click()
On Error GoTo Err_delete_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_delete_Click:
Exit Sub

Err_delete_Click:
MsgBox Err.Description
Resume Exit_dCommand20_Click

End Sub
 
Code:
Dim msg As String, button As Variant, title As String, response As Variant
msg = "Vehicle is Shopped - Do you want to dispatch anyway?"
button = vbYesNo + vbDefaultButton2
title = "Vehicle Shopped!"

response = MsgBox(msg, button, title)
If response = vbYes Then
  'what to do if yes
Else
  'what to do if not
End If
 
Try setting the warnings true:

Private Sub delete_Click()
On Error GoTo Err_delete_Click

docmd.setwarnings true

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_delete_Click:
Exit Sub

Err_delete_Click:
MsgBox Err.Description
Resume Exit_dCommand20_Click

End Sub[/QUOTE]
 
docmd.setwarnings true

Unfortunately, it did not work. Amazing how poor those wizards are? There must be some code that relly works. Thanks away. I am stuck.
 
Don't fear.... there are a lot of amazingly clever and helpful people on these forums, your problem will be solved.
 
Did you try pbaldy's trick? I hadn't realised he had posted just before I did, I would follow his advice for delete confirm.
 
Delete confirmation

I got the code from the search option and from a good soul. Here it is FYI:

If MsgBox("Are you sure you want to delete the current record?", vbQuestion + vbYesNo, "Delete Record?") = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else 'user clicked no
MsgBox "Deletion was aborted.", vbInformation
End If

And it works fine, as well as being understandable. Thanks to this good form, I learned something new.
 
This Forum is Tops!!! Glad you had it sorted out.
:D
 
One more "TIP" for you.

Be sure to put an error handler in there and set warnings back to true in it so that if it errors out while running your commands, you won't suddenly find yourself without errors at all (which it WILL do if it can't get to the part to set warnings true again).
 

Users who are viewing this thread

Back
Top Bottom