Combine multiple reports into one

Posted by: djanim8 on 4 August 2017, 2:32 pm EST

  • Posted 4 August 2017, 2:32 pm EST

    Is there any way to combine X number of reports into one report to be saved/printed?
  • Replied 4 August 2017, 2:32 pm EST

    Yes you can use a reports Pages.Insert method.  Here is an example where I have a main container report, rptFinal, a static backer, rptBacker, and the actual data driven report, rptReport.  I run all three then loop through the pages collection of the data driven report, instert it's pages and static backer pages so I can print front (data) and back (static), two copies of each in a white/pink scenario.  You should be able to take the basic idea and modify it to fit your needs.<BR><BR><FONT face="Courier New">rptReport.Run False<BR>rptBacker.Run False<BR><FONT color=#008000>'rptFinal.Run False  'removed as this creates a blank page at the end, Edit on 3/13/2006</FONT><BR>        <BR><FONT color=#008000>'load backwards so it is correct when finished</FONT><BR>For intP = (rptReport.Pages.Count - 1) To 0 Step -1<BR>  rptFinal.Pages.Insert 0, rptReport.Pages.Item(intP)<BR>  rptFinal.Pages.Insert 0, rptBacker.Pages.Item(0)<BR>            <BR>  rptFinal.Pages.Insert 0, rptReport.Pages.Item(intP)<BR>  rptFinal.Pages.Insert 0, rptBacker.Pages.Item(0)<BR>Next intP<BR>rptFinal.Pages.Commit<BR>rptFinal.Printer.FromPage = 1<BR>rptFinal.Printer.ToPage = (rptFinal.Pages.Count - 1)<BR>rptFinal.PrintReport False</FONT>
  • Replied 4 August 2017, 2:32 pm EST

    <P>Thanks for this code, it's helping me for the most part.</P>
    <P>But I'm having a problem in that the reports are getting inserted in reverse order. One of the tasks when generating a multiple-report report is to loop through a table of orders. The order reports are getting inserted in reverse order.</P>
    <BLOCKQUOTE dir=ltr>
    <P><FONT face="Courier New" size=2>So if I run things in this order:</FONT></P>
    <P><FONT face="Courier New" size=2>Generate Customer Contact report<BR>Query to select Order History records, loop through records<BR>Insert Order History report for 2005<BR>Insert Order History report for 2002<BR>Insert Order History report for 1999<BR>Export as one single report</FONT></P>
    <P><FONT face="Courier New" size=2>I get the following, coming out in reverse order:</FONT></P>
    <P><FONT face="Courier New" size=2>Order History report for 1999<BR>Order History report for 2002<BR>Order History report for 2005<BR>Customer Contact report</FONT></P></BLOCKQUOTE>
    <P>I know this is because we are using "Insert"... is there another way of doing this so it's an "Append" instead?<BR></P>
    <P><STRONG>EDIT:</STRONG> OK, nevermind, I got it to work the way I wanted to. I created a blank page report first (like in the poster's example). Executed a query to select the Order History recordset in reverse descending order, ran and inserted the Order History reports into the blank page report, then ran the Customer Contact report and inserted it. This left me with all the reports in correct order but with a blank page at the end. My final command then was to call the method <FONT face="Courier New" size=2>objARBlank.Pages.Remove (objARBlank.Pages.Count - 1)</FONT></P>
    <P>Wow, if there is an easier way (HINT: There needs to be a <STRONG><FONT face="Courier New" size=2>Pages.APPEND</FONT></STRONG> method!), please let me know. This works, but it reminds me frighteningly of writing bubble sorting code in high-school Pascal class.</P>
    <P> </P>
  • Replied 4 August 2017, 2:32 pm EST

    <P>If you don't run the Final / blank report you can avoid the empty page scenario.</P>
    <P>The following should function the same as an APPEND method. If I was just interested in combining reports together for exporting or viewing I would use the following, which also negates the need for a blank container object. If like I was originally doing with my previous post in this thread of creating a duplicate report for carbonless printing with a static backer I would use that previous code.</P>
    <P><FONT face="Courier New">For intP = 0 To rptFrom.Pages.Count - 1<BR>   rptInto.Pages.Insert rptInto.Pages.Count, rptFrom.Pages(intP)<BR>Next intP<BR>rptInto.Pages.Commit</FONT></P>
  • Replied 4 August 2017, 2:32 pm EST

    And (this may not be of interest) you can manually create a TOC for this combined report if required. I gave brief details in a recent comment to another posting but will be happy to explain more if asked. (I am using AR1 with VB6)
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels