Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 11:02 AM
ChadDiesel
Guest
 
Posts: n/a
Default Collate 2 Different Reports

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


  #2  
Old November 13th, 2005, 11:03 AM
David Lloyd
Guest
 
Posts: n/a
Default 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



 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles