troubleshooting Question

Delete Button in Access 2016

Avatar of urjudo
urjudoFlag for United States of America asked on
Microsoft Access* Delete coding
16 Comments1 Solution59 ViewsLast Modified:
H Experts,
I have a question about running a Delete query in VBA code in Access 2016.
below is my code:

Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

   Dim Msg as String
   Dim Response as Integer

   Msg = "You are about to delete the following action from the table: " & vbCrLf & vbCrLf
   Msg = Msg & vbTab & Prod#: " & vbTab & Form_frmProduct.ProdNum & vbCrLf
   Msg = Msg & vbTab & "Entered on : " & Form_frmProduct.EnterDate & vbCrLf
   Msg = Msg & vbTab & "Entered by : " & Form_frmProduct.EnterUser & vbCrLf

  Msg = Msg & vbCrLf & "       Do you want to delete this record>"
  Response = MsgBox(Msg, vbYesNo + vbApplicationModal + vbQuestion + vbDefaultButton2, "Delete confirmation")
  If Response = vbYes then
      docmd.openQuery "qryDeleteProduct"
      docmd.close acForm, "frmProduct"
  End if

What I want to do is once the "Delete confirmation" screen pop up, users click Yes then every will be done and close the form instead showing "You're about the run a delete query that will modify data in your table" then users have to click "Yes" then another pop up screen "You are about to delete 1 row(s) from the specified table" then users have to click "Yes" again to delete the record.  Any suggestion will be very appreciated!
Join our community to see this answer!
Unlock 1 Answer and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros