Help! Collating reports to print

C

Christine

I have 4 reports that I want to print (no preview)one
after the other. The problem is, each report needs about 5
minutes to run before being sent to the printer. So when I
try to do this, I get an error that it cannot print a
document that is still running. How can I get the reports
to print after they have thoroughly completed running
without previewing. Here is my code: It is on open of the
first report, then calls the next 3...

Private Sub Report_Open(Cancel As Integer)

'In here is a lot of code creating temp tables to run
Report 1, then...

Call PrintAllReports
End Sub

Public Function PrintAllReports()
DoCmd.OpenReport "rpt2", acViewPreview
DoCmd.OpenReport "rpt3", acViewPreview
DoCmd.OpenReport "rpt4", acViewPreview
End Function
 
F

fredg

I have 4 reports that I want to print (no preview)one
after the other. The problem is, each report needs about 5
minutes to run before being sent to the printer. So when I
try to do this, I get an error that it cannot print a
document that is still running. How can I get the reports
to print after they have thoroughly completed running
without previewing. Here is my code: It is on open of the
first report, then calls the next 3...

Private Sub Report_Open(Cancel As Integer)

'In here is a lot of code creating temp tables to run
Report 1, then...

Call PrintAllReports
End Sub

Public Function PrintAllReports()
DoCmd.OpenReport "rpt2", acViewPreview
DoCmd.OpenReport "rpt3", acViewPreview
DoCmd.OpenReport "rpt4", acViewPreview
End Function

Don't open the other reports from the first report's Open event.
Use each report's Close event to open the next report.
In the Report1 Close event:
DoCmd.OpenReport "Report2"
In the Report2 Close event:
DoCmd.OpenReport "Report3"
etc.

This way each report takes as much time as it needs to run.
 
C

Christine

-----Original Message-----


Don't open the other reports from the first report's Open event.
Use each report's Close event to open the next report.
In the Report1 Close event:
DoCmd.OpenReport "Report2"
In the Report2 Close event:
DoCmd.OpenReport "Report3"
etc.

This way each report takes as much time as it needs to run.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
Thanks so muich Fred!>
 
C

Christine

-----Original Message-----


Don't open the other reports from the first report's Open event.
Use each report's Close event to open the next report.
In the Report1 Close event:
DoCmd.OpenReport "Report2"
In the Report2 Close event:
DoCmd.OpenReport "Report3"
etc.

This way each report takes as much time as it needs to run.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
Still need help -I tried that and because the report
doesn't actually "open" (it just goes straight to the
printer)it never actually "closes". I did a break point
and it never gets to "on close" event procedure. Other
ideas?
 
F

fredg

Still need help -I tried that and because the report
doesn't actually "open" (it just goes straight to the
printer)it never actually "closes". I did a break point
and it never gets to "on close" event procedure. Other
ideas?

Add a Report Footer (even if you don't need one) to each report.
Place the code in the Report Footer Format event.

If you don't need the Report Footer, code the Format event:

DoCmd.OpenReport "ReportX"
Cancel = True

The report Footer only runs at the end of the report.
The event will run, open the report, then be canceled, so it won't
show in the current report.
 
F

fredg

Add a Report Footer (even if you don't need one) to each report.
Place the code in the Report Footer Format event.

If you don't need the Report Footer, code the Format event:

DoCmd.OpenReport "ReportX"
Cancel = True

The report Footer only runs at the end of the report.
The event will run, open the report, then be canceled, so it won't
show in the current report.

Christine,
I should have thought twice before I posted.
Running the OpenReport command in a Report event (even through a sub
procedure or function, as you have) causes Error #2046 "Command or
Action OpenReport isn't available now."
It's not that the event doesn't fire when printing, it does.
You just can't use that command.

Sorry I mislead you.

I know you can run the reports consecutively by opening them, one
after the other, in a form's command button event, or in a module sub
procedure.

Perhaps you can move that code to a form button event, coded:
DoCmd.OpenReport "Report1"
DoCmd.OpenReport "Report2"
DoCmd.OpenReport "Report3"
etc.

I don't know what effect your 5 minute delay would have on it, if any.
In any event, it wasn't the delay causing your initial problem, but
the fact you were using a report event to try to open the other
reports.
 

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

Similar Threads


Top