Are you sure that you want to execute this macro : Yes or No

  • Thread starter Thread starter Céline Brien
  • Start date Start date
C

Céline Brien

Hi everybody !
Acess 97
At the beginning of a macro, I would like a dialog box to appear with a
question : Are you sure that you want to execute this macro ? and two
buttons Yes and No.
Thank you for your help,
Céline
 
Dim Prompt As String, Title As String, Response As Variant
Title = "Preparing to Run Macro"
Prompt = "Want to Continue?"
Response = MsgBox(Prompt, vbInformation + vbYesNo, Title)
If Response = vbNo Then
Exit Sub
ElseIf Response = vbYes Then
'Run the Macro here....
End If

hth
Al Camp
 
Céline

In a macro, you would use a Condition. In the design view of the macro,
if you can't see the Condition column select it from the View menu.
Then, type something like this...

MsgBox("Are you sure?",4,"Confirm")=6

If there are more than one action in the macro, you should put this in
the Condition for the first action, and then put ... in the condition
for the subsequent actions.
 
Hi Al,
Thank you for your answer.
I used Steve solution but I keep yours in my archive.
Céline
 
Steve,
I want to do the same thing as Celine, but I do not understand your answer.
I want to do this in a Macro, not with VB. When you create a Msgbox in a
Macro the only answer available is "OK". If a response can be solicited in a
macro (not using the MsgBox function of VB), please clarify.

Thanks
 
GeorgieGirl,

Please follow the directions I gave in the example to Céline. This is
using a MsgBox function in the macro Condition, which is different from
the MsgBox macro action. Give it a try, and post back if you still
can't get it.
 
Steve,
Thank you so much for your help. It workd perfectly, of course! I have
done several applications in Access, but only using Querys, Macros, Forms,
etc. and regular "If [control] > than 5" conditions in Macros. I did not
know that functions could be used unless you were writing code. This has
opened up a whole new avenue for me to streamline my applications. This site
is fantastic.
 
Back
Top