We help IT Professionals succeed at work.
Get Started

Delete Button in Access 2016

urjudo asked
Last Modified: 2020-03-21
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!
Watch Question
Most Valuable Expert 2015
Distinguished Expert 2018
This problem has been solved!
Unlock 1 Answer and 16 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE