• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

A confirmation box to print a large report

Greetings,

I have a macro that prints 6 separate reports.  I thought I could simply add a msgBox before the print lines in the macro that says "This will print 5 reports . . . bla bla. Are you sure you want to continue" with the option to continue the macro or cancel.

But any of the message types do not automatically  allow this continue or cancel like I thought it might, so how do I accomplish this within the macro?

Thanks
0
Mixmangle
Asked:
Mixmangle
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Assuming you're doing this with a button, then put this in the Click event of that button:

If Msgbox("Are you sure you want to continue?", vbYesNo, "Confirm Print") <> vbNo Then
  Exit Sub
End If

Docmd.OpenReport "Report1", acViewPreview
doCmd.OpenReport "Report2", acViewPreview
etc etc
0
 
TWBitCommented:
To do this solely in a macro, turn on macro conditionals (View|Conditions)

As the first line of the macro, in the Conditions column, enter

MsgBox("Do you want to print all the reports?",4)=7

and next to it, in the Action column, put StopMacro.


But it's better to do this stuff in code - much more flexible,

0
 
dqmqCommented:
In macro designer, click on the View menu to open up the conditions column.  Add a line before printing the first report and put this in the conditions column:

MsgBox("Do you want to continue?",1)<>1

In the action column, put StopMacro.

Now, when that line is encountered, the Msgbox will pop up and the macro will stop, depending on how it is answered.  You can play around with different buttons and return values from the msgbox function, but I think you get the idea.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
dqmqCommented:
Oh well, a little late...
0
 
TWBitCommented:
:)  Here is a link to all the message box types and return values: http://msdn2.microsoft.com/en-us/library/aa445082.aspx
0
 
MixmangleAuthor Commented:
Bingo.  I was unaware of the Macro Conditions View.  I knew it could be done within the macro, but wasn't seeing it!  Your link to all the number types really helped too!
0
 
TWBitCommented:
Great, glad it works for you.  Let us know when you switch to coding instead of macros - we're here to help!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now