Set all reports to print to default printer

M

Mark Hammer

Before shipping an updated version of my app, I'd like to insure that all
reports are set to print to the default printer.

Seems simple, but I'm missing something. Here's the code I tried:

=============
Dim rpt As Report

For Each rpt In Application.Reports
' open it in design view
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
If rpt.UseDefaultPrinter = False Then
Debug.Print rpt.Name, " Changed."
rpt.UseDefaultPrinter = True
DoCmd.Close acReport, rpt.Name, acSaveYes
Else
Debug.Print rpt.Name, " OK."
DoCmd.Close acReport, rpt.Name, acSaveNo
End If
DoEvents
Next rpt
=============

However, the "For Each rpt" feature seems not to work. The code never goes
into the "For Each . . . Next" loop, instead skipping to the code line
following "Next rpt".

Help appreciated!

Mark Hammer
Lake Oswego, Oregon, U.S.
 
M

Mark Hammer

Should have said I'm using Access 2002.

And I just realized that the Reports collection refers only to OPEN reports,
which explains why my code wasn't entering the loop.

Remaining problem is, how to iterate thru all the reports which are not
open?

--Mark Hammer
 

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