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.