Message Box Reminder in Macro

G

Guest

Hi
I have set up a macro but I want to add a message asking the user if he/she
has performed certain tasks prior to running the macro. The only message box
I can find only has an 'OK' button. I want one where the user can opt not to
run the macro and go back and perform the tasks if he/she has forgotten them,
then run the macro.

Any ideas - I'm using Access 97.

Thanks in anticipation.

GLS
 
K

Ken Snell \(MVP\)

Try this as your Condition in the macro action that will stop the macro if
the user clicks the No button on the message box:

MsgBox("Did you do the task first?", 4, "Task Done?")=7

See MsgBox in Help file for more information about the various integer
values that are used to represent the choice of buttons, the button that the
user clicks, etc. Or see this MSDN article:
http://msdn2.microsoft.com/en-us/library/139z2azd.aspx
 
G

Guest

Ken

Thanks for your help - I've set the condition as you describe and I get the
message box coming up Ok, but, I'm not clear as to what I should have in the
'Action' column of the macro design view.

Sorry if I seem stupid

Regards

Gavin
 
S

Steve Schapel

Gavin,

What do you want the macro to do, assuming the user confirms that he
should go ahead?

Ken's suggestion works on the basis that if the user clicks the No
button, nothing will happen, i.e. he will be returned to the prior
screen, presumably to complete the unfinished tasks. But if he clicks
the Yes button, the macro will do whatever your original intention was.
 
S

Steve Schapel

Oops! As soon as I hit 'Send', I know I had that wrong. My apologies,
I didn't read Ken's post carefully enough. His suggestion will test for
the user clicking the No button. Maybe it would be more applicable to do:
MsgBox("Did you do the task first?", 4, "Task Done?")=6
It is the Yes answer you want in order to proceed with the macro, I think.
 
K

Ken Snell \(MVP\)

"Try this as your Condition in the macro action that will stop the macro if
the user clicks the No button on the message box"

Yep, my intent was that the action would be a StopMacro for the step that
goes with the condition expression that I posted.
;-)
 
G

Guest

Ken/Steve

Thanks guys - I got it to work using the
'MsgBox("Did you do the task first?", 4, "Task Done?")=7'
Condition plus the 'StopMacro' Action. If I click 'No' the macro goes back
to the previous screen, if I click 'Yes' the macro runs, which is exactly
what I wanted.

I originally had used the condition with the 'MsgBox' action and whether I
clicked 'Yes' or 'No' it proceeded to the 'OK' Message Box which would run
the macro, so I didnt have a stop macro option despite the inclusion of the
condition.

Thanks for your help guys.

Regards

Gavin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top