Pop up message in ACCESS Macro

Hello -

I have append queries that I run on a monthly basis.  I am charging a co-work to run these.  I have a form with a button (macro) that will run the append queries.  However, I want to add a pop up massage when the macro button is selected that will say something like "You are about to append your data - are you sure you want to proceed".  If possible, a yes or no button afterwards.

Is this possible???  If so - can someone provide detailed steps to do this?  I've never done this before.

Thanks
vpopperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JoeMiskeyCommented:
Is your button running a Macro or VBA code?
If it is running a macro, convert your Macro to VBA.  This is pretty easy.  Just highlight the Macro, go to the Database Tools menu and under the Macro ribbon select "Convert Macros to Visual Basic".

Then, go to the On Click Property of your button, select Code Builder.  This should set up the an empty Event Procedure shell for you.  Enter code something like this:
    Dim myMsgBox
    myMsgBox = MsgBox("You are about to append your data - are you sure you want to proceed?", vbYesNo, "ATTENTION!")
    If myMsgBox = vbYes Then
        'Enter your code here
    Else
        MsgBox "Process cancelled!"
    End If

Open in new window

Then, on that line where I have the comment 'Enter your code here, i the VB Editor browse to the Converted Macros, and copy everything between the first and last lines (leave the Function... and End Function lines off and paste them where that comment is.

If your button is already running VBA code, you should just be able to add the structure of the code I showed above.

That should do what you want.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
In the simplest terms, ...your code would look something like this:
Dim strSQL1 as string
Dim strSQL2 as string
'...etc
Dim bytAnswer as byte
strSQL1 ="YourAppend Query SQL here"
bytAnswer =msgbox(""You are about to append your data - are you sure you want to proceed",vbyesNo+vbquestion)
If bytAnswer =VBNO Then
   Exit Sub
End If
'YourCode to run your append queries
CurrentDB.Execute strSQL1,dbfailonerror
CurrentDB.Execute strSQL2,dbfailonerror
'...etc

Note the by default Access will ask you to approve running "Action" queries.
So even if you added your own, ...Access would still ask you.

You can turn off the warnings (from the Access Options), ...but the other issue is what happens if one of the queries fails?
If the results of the first query are used in the second query, ...Then how would you know if the first query produced the correct output.
Anything can go wrong in any "unattended" systems.
So you may also need to add robust error handling and possibly rollbacks in your code.


JeffCoachman
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.