Home Subreports
New Blog Posts: Merging Reports - Part 1 and Part 2

Loading a subreports template at runtime based on main report detail data

edited February 2005 in Subreports
Hi,

Is there a way to change the template of a subreport multiple times
during a report based on the detail data in the main report?

Example:

In a method like Band BeforeGenerate - the subreport is in this band
Get Template needed for current record and place in a stream
Subreport.LoadFromStream(Stream)

I have tried multiple ways to accomplish this but it always has some bad
side affects. It seems like it almost works except one way last record
will not print or another way the report will continue to print blank
pages etc, etc.

Am I trying the impossible?

Any thoughts would be greatly appreciated.

Darryl

Comments

  • edited February 2005

    1. Use BeforePrint rather than BeforeGenerate.

    2. Rather than loading the report templates while the report is generating.
    Create separate subreports that contain the various layouts prior to calling
    Report.Print. Use the Report.BeforePrint event to set subReport.Visible for
    each subreport.


    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2005
    There are at least two problems doing it this way.

    1. When using a section type of subreport there will be a page printed
    before each subreport. I must be able to get it to print one subreport
    after another without any pages between the subreports.

    2. If it is a child the subreport's header and footer will not print.
    The templates are created by end users and it is a requirement that they
    have headers and footers not just group headers/footers.

    Maybe some more info would be in place.

    The end user can create different templates. The templates are assigned
    to overhead db file like "Customers". When the user needs to print
    invoices then for each invoice in the main datapipeline we need to use
    the template that the user has assigned to the customer. It is not a
    option to print a single customer or a single template type at a time.

    Maybe using subreports is the wrong way to approach this.

    Would there be a way for me to use subclassing to get a single invoice
    to print then change the template print another invoice ... but have
    them all put in the same output device?

    Could it be as simple as appending to the archive file for each invoice
    then being able to read it out of the archive file as if it was one report?
  • edited February 2005

    1. I did not mention using section subreports. Please reread my response.

    2. To create a report that consists of multiple section subreports that
    print one after another, you need to create a main report and remove the
    header and footer so that it has on the detail band. Place the section
    subreports in the detail band.

    3. Correct pbChild subreport header/footer will not print. You can use Group
    Header/GroupFooter or Title/Summary. (A pbSection subreport will print its
    own header/footer).

    If you would like to create an example that we can run here, please send in
    zip format to support@digital-metaphors.com and we can check it out here.




    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2005
    Thanks for your time.

    The page problem I was having was due to our framework the header and
    footer were being recreated before the print.

    Darryl Koehn
This discussion has been closed.