I have 3 reports that I need to print before moving to the next record. The Reports are named RMSection1 (3 Pages), RMSection2(4 Pages) , & RMSection3 (1 page).
I found some code from MS but I can't get it to work can anyone help?
The following code example sounds exactly like what I need to do except I have 3 reports.
To collate and print two reports and to test the results, follow these steps:
Open the sample database NWIND.MDB.
Create a new module and type the following lines in the Declarations section:
'****************************************************************
'Declarations section of the module
'****************************************************************
Option Compare Database
Option Explicit
Type the following function:
'**********************************************************************
'NumPages is the number of pages in the largest report. If one report
'has fewer pages, the DoCmd Print statement for the smaller report runs
'correctly and no additional pages are printed.
'**********************************************************************
Function CollateReports(NumPages, Rpt1 As String, Rpt2 As String)
Dim MyPageNum As Integer
' Set the page number loop and alternate printing the report pages.
For MyPageNum = 1 To NumPages
' NumPages is the number of pages to print.
DoCmd SelectObject A_REPORT, Rpt1, True
DoCmd Print A_PAGES, MyPageNum, MyPageNum
DoCmd SelectObject A_REPORT, Rpt2, True
DoCmd Print A_PAGES, MyPageNum, MyPageNum
Next MyPageNum
End Function
To test the results, type the following line in the Immediate Window, and then press ENTER:
Print CollateReports(1, "Sales summaries", "Sales Totals by amount"
Note that Microsoft Access prints one page from each report.
End Function
I found some code from MS but I can't get it to work can anyone help?
The following code example sounds exactly like what I need to do except I have 3 reports.
To collate and print two reports and to test the results, follow these steps:
Open the sample database NWIND.MDB.
Create a new module and type the following lines in the Declarations section:
'****************************************************************
'Declarations section of the module
'****************************************************************
Option Compare Database
Option Explicit
Type the following function:
'**********************************************************************
'NumPages is the number of pages in the largest report. If one report
'has fewer pages, the DoCmd Print statement for the smaller report runs
'correctly and no additional pages are printed.
'**********************************************************************
Function CollateReports(NumPages, Rpt1 As String, Rpt2 As String)
Dim MyPageNum As Integer
' Set the page number loop and alternate printing the report pages.
For MyPageNum = 1 To NumPages
' NumPages is the number of pages to print.
DoCmd SelectObject A_REPORT, Rpt1, True
DoCmd Print A_PAGES, MyPageNum, MyPageNum
DoCmd SelectObject A_REPORT, Rpt2, True
DoCmd Print A_PAGES, MyPageNum, MyPageNum
Next MyPageNum
End Function
To test the results, type the following line in the Immediate Window, and then press ENTER:
Print CollateReports(1, "Sales summaries", "Sales Totals by amount"
Note that Microsoft Access prints one page from each report.
End Function