I have code that loops through some statements, previewing the same report
each time through. After the first report previews and I close it, the loop
seems to end and will not prewiew the remaining pages. If I insert a
Docmd.Close (report) in the loop, the report opens and closes without being
able to view it.
How can I preview the report, then wait for a user to press the "Close"
button on the report toolbar before progressing trough the loop and
displaying the next report?
Rick Brandt - 19 Mar 2005 14:34 GMT
>I have code that loops through some statements, previewing the same report
> each time through. After the first report previews and I close it, the loop
[quoted text clipped - 5 lines]
> on the report toolbar before progressing trough the loop and displaying the
> next report?
You can't unless you do something to stop your code loop. If every report were
only one page and you didn't need to change the zoom level you could open the
form and then open a msgbox or a dialog form. That would pause your code loop
until that was closed. You wouldn't be able to interact with the report at all
though.
If this was the only way you wanted to view the reports you could drop the loop
and just have the close event of each report automatically open the next one.

Signature
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Jim Pockmire - 20 Mar 2005 02:21 GMT
Each report is more than 1 page. I have tried to insert a msgbox at the on
close event, but this disrupts viewing the report. I can probably find a
work around if that is the only option.
>>I have code that loops through some statements, previewing the same report
>> each time through. After the first report previews and I close it, the
[quoted text clipped - 16 lines]
> loop and just have the close event of each report automatically open the
> next one.
John Spencer (MVP) - 20 Mar 2005 17:12 GMT
What version of Access?
I believe - can't test this here - that Access 2003 allows you to open a report
in dialog mode. In earlier versions, you could test whether or not the report
was open within a loop. If it was then you would execute a DoEvents and NOT
progress to the next report in the loop
UNTESTED CODE Snippet for Access 97 to Access 2003 - banged this together and it
is very probable that this is not the most efficient code
Public Sub sTest()
Dim rptAny As Report
Dim tfStillOpen As Boolean
'Start of Your Loop Code
DoCmd.OpenReport "rpt_WorkTimeSpent", acViewPreview
tfStillOpen = True
While tfStillOpen = True
tfStillOpen = False
For Each rptAny In CurrentDb().Reports
If rptAny.Name = "rpt_WorkTimeSpent" Then
tfStillOpen = True
DoEvents
Exit For
End If
Next rptAny
Wend
'End of your loop code
End Sub
> I have code that loops through some statements, previewing the same report
> each time through. After the first report previews and I close it, the loop
[quoted text clipped - 5 lines]
> button on the report toolbar before progressing trough the loop and
> displaying the next report?