Connecting Tech Pros Worldwide Forums | Help | Site Map

Collate 2 Different Reports

ChadDiesel
Guest
 
Posts: n/a
#1: Nov 13 '05
Hello,

I have 2 reports that I want to collate (Report 1-Page 1, Report 2-Page 1,
Report 1-Page 2, Report 2-Page 2). I used the following code in a module I
found in Microsoft support article 231805:

Option Compare Database

'***********************************
'Declarations section of the module
'***********************************
Option Explicit
'************************************************* ********************
'NumPages is the number of pages in the largest report. If one report
'has fewer pages, the DoCmd.PrintOut 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 acReport, Rpt1, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt2, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
Next MyPageNum
End Function


This works great, but I have to specify the maximum # number of pages (1 in
this example) in:


? CollateReports(1, "Report 1", "Report 2")


Each week, the number of pages (1 per record) will be different. I can set
this value to a high number, but that sends a bunch of extra print jobs to
the printer. Even though no extra pages are printed, I'm sure there is a
better way. Is there a way to set the maximum number of pages
automatically?


Also, when I type

? CollateReports(1, "Report 1", "Report 2")

In the Immediate window, it prints fine with no error, but when I paste this
code into the on click event of a button on my form:


Private Sub Command16_Click()

Print CollateReports(1, "Report 1", "Report 2")

End Sub


it still prints fine, but I get this error:


Run-time error '438':

Object doesn't support this property or method.


Any help would be appreciated.


Thank You,

Chad



David Lloyd
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Collate 2 Different Reports


Chad:

Another approach that you may want to consider is to make one report a
subreport of the other. Depending on where you embed the subreport in the
master report you can control the collation between the two reports.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


"ChadDiesel" <shaqattack1992-newsgroups@yahoo.com> wrote in message
news:tyuie.3713$uR4.46@newsread2.news.atl.earthlin k.net...
Hello,

I have 2 reports that I want to collate (Report 1-Page 1, Report 2-Page 1,
Report 1-Page 2, Report 2-Page 2). I used the following code in a module I
found in Microsoft support article 231805:

Option Compare Database

'***********************************
'Declarations section of the module
'***********************************
Option Explicit
'************************************************* ********************
'NumPages is the number of pages in the largest report. If one report
'has fewer pages, the DoCmd.PrintOut 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 acReport, Rpt1, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt2, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
Next MyPageNum
End Function


This works great, but I have to specify the maximum # number of pages (1 in
this example) in:


? CollateReports(1, "Report 1", "Report 2")


Each week, the number of pages (1 per record) will be different. I can set
this value to a high number, but that sends a bunch of extra print jobs to
the printer. Even though no extra pages are printed, I'm sure there is a
better way. Is there a way to set the maximum number of pages
automatically?


Also, when I type

? CollateReports(1, "Report 1", "Report 2")

In the Immediate window, it prints fine with no error, but when I paste this
code into the on click event of a button on my form:


Private Sub Command16_Click()

Print CollateReports(1, "Report 1", "Report 2")

End Sub


it still prints fine, but I get this error:


Run-time error '438':

Object doesn't support this property or method.


Any help would be appreciated.


Thank You,

Chad



Closed Thread