One report - multiple print files

K

KLP

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
 
R

Rick Brandt

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.
 
S

sangee

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

Sangee
 
K

KLP

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.
 

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