Button to print several reports

A

Alex

Does anyone know some code to put behind a button on a form that will print,
for example, rpt1, rpt2, rpt3, when a user selects a printer from the print
dialog box and clicks the OK button? Currently the print dialog box opens
for each report and I only want it to open once, but print all 3 reports.

I can't indicate the printer in the code because users will be selecting
different printers.

Also, if the cancel button is selected or if the dialog box is closed (and
the OK button not selected), I don't want the reports to print.

Thanks for your help.
 
A

Allen Browne

If you are using Access 2002 or later (2003, or 2007), you could create a
form with a combo box populated from the Printers collection (the DeviceName
of each), so the user can choose one. Your form can then assign the Printer
to this one, and print the report. Then clear the Printer (by setting it to
Nothing) before the form closes.

If you have never used the Printer collection before, download the example
utility in this page:
http://allenbrowne.com/AppPrintMgt.html
The form shows how to load the combo with the printers, and let the user
choose one. The utility then identifies that printer with the report, and
remembers to use it again next time (which is not what you asked for, but
hopefully illustrates how to do it.)
 
A

Alex

Unfortunately, most users are still on Access 2000. I should have mentioned
that. Is there another way I can accomplish this? Thanks Allen.
 
C

Chuck

Does anyone know some code to put behind a button on a form that will print,
for example, rpt1, rpt2, rpt3, when a user selects a printer from the print
dialog box and clicks the OK button? Currently the print dialog box opens
for each report and I only want it to open once, but print all 3 reports.

I can't indicate the printer in the code because users will be selecting
different printers.
If each user can open the reports manually one at a time and then select print
and each report will automatically print to a default printer, then you should
not have to program which printer to use. A non programmers approach to this
problem is to write a separate macro to print each report. Then write an extra
macro that calls each of the separate macros one after another.

Put a command button on your form that runs the macro that calls the separate
macros
Also, if the cancel button is selected or if the dialog box is closed (and
the OK button not selected), I don't want the reports to print.

Thanks for your help.

I'm running A97. When I run a macro to print a report, the report does not
open for viewing and the printer dialog box does not open, thus not giving me
the option to cancel.

What situations might cause the user to not want to print one or more of the
reports?

Chuck
 
A

Alex

Thanks Chuck. We can't assume that each user will want to print to his/her
default printer so we need to allow them to choose a printer.
 
C

Chuck

Thanks Chuck. We can't assume that each user will want to print to his/her
default printer so we need to allow them to choose a printer.
If each user will always print to the same printer, default or not, The user
can open the report in view mode, click on file/print. A print dialog box will
open. Select the desired printer. Print the report. Save the report.
Thereafter each time the report is opened it will try to print to the same
printer as originally selected. If the user wants to select a different
printer every time a report is printed, and wants to select which printer
before the report is opened so he/she doesn't have to look at a print dialog
box, then someone needs to write some specialized code for your program. I'm
sure it is possible by a dozen or more readers of this news group, but not by
me. If the user has to select a printer every time, why not do it in the print
dialog box? This is beginning to look more like an exercise just to see if you
can figure out how to do it than it is to serve some practical purpose.

Chuck
--
 

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