Pause between reports

  • Thread starter Thread starter JimP
  • Start date Start date
J

JimP

I have code that previews several reports. How can I close each report
(pause) before previewing the next report? e.g. the code below opens all
reports at the same time

Sub RunReports()
DoCmd.OpenReport "ReportA", acViewPreview
DoCmd.OpenReport "ReportB", acViewPreview
DoCmd.OpenReport "ReportC", acViewPreview
DoCmd.OpenReport "ReportD", acViewPreview
End Sub
 
No way to know when Report A is closed.
You could put te code in Report A's Close event to open Report B, etc.
 
JimP said:
I have code that previews several reports. How can I close each report
(pause) before previewing the next report? e.g. the code below opens all
reports at the same time

Sub RunReports()
DoCmd.OpenReport "ReportA", acViewPreview
DoCmd.OpenReport "ReportB", acViewPreview
DoCmd.OpenReport "ReportC", acViewPreview
DoCmd.OpenReport "ReportD", acViewPreview
End Sub


What version of Access are you using? In Access 2003, the OpenReport method
has a WindowMode argument that can be used to open a report in dialog mode.
If your code opened each of those reports in dialog mode; e.g.,

DoCmd.OpenReport "ReportA", acViewPreview, , , acDialog

.... then presumably each successive line of code would not be executed until
the previous report was closed.

However, that may not give you the look and functionality you want, as
dialog mode doesn't give you the print-preview toolbar.

If it's worth your trouble, it would probably be possible to write code that
uses Windows API calls to (a) wait until the report's preview window is
displayed, and then (b) wait until that window is closed.
 
Dirk's suggestion is the best one if you're using Access XP or later. If
you're using something earlier than that, let me know. I'm pretty sure I've
got some code archived away from a few years ago (before Access XP) that
uses Windows API calls to wait until the report is closed before returning.


Rob
 
JimP said:
I have code that previews several reports. How can I close each report
(pause) before previewing the next report? e.g. the code below opens all
reports at the same time

Sub RunReports()
DoCmd.OpenReport "ReportA", acViewPreview
DoCmd.OpenReport "ReportB", acViewPreview
DoCmd.OpenReport "ReportC", acViewPreview
DoCmd.OpenReport "ReportD", acViewPreview
End Sub

Probably a bad idea, but you could open the reports in
dialog mode.

Another hokey idea is to add a loop between each OpenReport:

Do While CurrentProject.AllReports!ReportA.IsLoaded
DoEvents
Loop
 
Marshall Barton said:
Another hokey idea is to add a loop between each OpenReport:

Do While CurrentProject.AllReports!ReportA.IsLoaded
DoEvents
Loop


I completely forgot about using IsLoaded to determine whether the report is
open! That's probably simple enough to be worthwhile for JimP.
 
Back
Top