One report - multiple print files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to run a report and have it create multiple outputs based on
customer record? The 'multiple' output could be PDF or Excel files.

Any ideas would be appreciated.

Kelvin
 
KLP said:
Is it possible to run a report and have it create multiple outputs
based on customer record? The 'multiple' output could be PDF or
Excel files.

Any ideas would be appreciated.

Kelvin

Normally one would use a loop mechanism to output them as individula reports
each one filtered on a customer.
 
sangee said:
Rick - know of any code that could help? I am running into the same
situation

-----------------------------------
Dim sql as String
Dim db as Database
Dim rs as Recordset

sql = "SELECT CustomerID FROM Customers"
Set db = CurrentDB
Set rs = db.OpenRecordset(sql, dbOpenSnapshot)

Do Until rs.EOF
DoCmd.OpenReport "ReportName", acViewPreview,,"CustomerID = " &
rs!CustomerID
DoCmd.OutputTo
acOutputReport,"ReportName",[YourFormatOption],[YourFileName]
DoCmd.Close acReport,"ReportName"
rs.MoveNext
Loop

rs.Close
Set rs = Nothing
Set db = Nothing
-----------------------------------

The reason to open the report in preview mode first is that when you ouput a
report to an external file and the report is already opened in preview mode,
the output file will use the same filter as that applied to the previewed
report. This is necessary because the OutputTo method does not provide a
mechanism for applying a filter like OpenReport does.

There are other ways to work around that, but this one is fairly simple to
implement.
 
Thank you for the info. Where does the code go?

Kelvin

Rick Brandt said:
sangee said:
Rick - know of any code that could help? I am running into the same
situation

-----------------------------------
Dim sql as String
Dim db as Database
Dim rs as Recordset

sql = "SELECT CustomerID FROM Customers"
Set db = CurrentDB
Set rs = db.OpenRecordset(sql, dbOpenSnapshot)

Do Until rs.EOF
DoCmd.OpenReport "ReportName", acViewPreview,,"CustomerID = " &
rs!CustomerID
DoCmd.OutputTo
acOutputReport,"ReportName",[YourFormatOption],[YourFileName]
DoCmd.Close acReport,"ReportName"
rs.MoveNext
Loop

rs.Close
Set rs = Nothing
Set db = Nothing
-----------------------------------

The reason to open the report in preview mode first is that when you ouput a
report to an external file and the report is already opened in preview mode,
the output file will use the same filter as that applied to the previewed
report. This is necessary because the OutputTo method does not provide a
mechanism for applying a filter like OpenReport does.

There are other ways to work around that, but this one is fairly simple to
implement.
 
Back
Top