I have a report that is 6 pages long for each record in a query. I want to be able to determine the number of records in the query, and then print pages 1-5 of the report for each of those records. The following code seems to work with the exception that when the PrintOut method is invoked, the object tblCountFedExClaims is active and not the report object rptReceiptofClaim_LtrFEDEX that I want to print. How can I make the report object active so that the printout method applies to it and not the table?
Set rs = CurrentDb.OpenRecordset("tblCountFedExClaims")
intNumRecords = rs!Count
Set rs = Nothing
DoCmd.OpenReport "rptReceiptofClaim_LtrFEDEX", acPreview
y = 1
For x = 1 To intNumRecords
'Print the first 5 pages for each SR
DoCmd.PrintOut acPages, y, y + 4, acHigh
'Set y = starting page of next SR
y = y + 6
DoCmd.Close acReport, "rptReceiptofClaim_LtrFEDEX"