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

SubReport

edited January 2007 in General
Hi, I have two subreports, side by side on a detail band. The problem is:
First subreport prints over 3 pages and the second subreport only print on
page 1. Is there a way to force the print of the second subreport over the
other 2 pages?

Thanks

Murilo

Comments

  • edited January 2007
    What I want to do is, basically, re-print the second subreport over the next
    two pages, to avoid any blank space, because second subreport has only 4
    records, and first subreport has 25 records.

    Thanks

  • edited January 2007
    Hi Murilo,

    One option may be to save the smaller subreport's template and dynamically
    create the number of subreport copies you need and load the template into
    each of the subreport objects. Though it would use multiple subreport
    object, it would give the impression that they are being copied.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2007
    Hum.. Ok. I will try that.

    Thanks for the idea Nico

  • edited January 2007
    Hi Nico, can you provide some basic code to dynamically create a subreport?

    I have saved the .rtm on a .rc file and compiled. I'm able to load it into a
    Resource variable and I know how to load it into a SubReport.

    Well, I've never created a subreport dynamically before.

    Thanks for your help and patience

  • edited January 2007
    -------------------------------------------------
    TECH TIP: Creating a SubReport in Code
    -------------------------------------------------

    A subreport is comprised of two objects:

    1. SubReport control
    The subreport control is added to a band of the
    'parent' report. It has properties such as
    ShiftRelativeTo, PrintBehavior, etc.
    In the Report Designer, the subreport is drawn
    as a rectangle.


    2. ChildReport
    The child report is a descendant of CustomReport and has
    most of the same properties as a standard Report.
    The child report has a separate layout workspace in the report
    designer that is accessible by selecting the tabs at the bottom
    of the designer.




    When dynamically creating a subreport in code you need to
    create the subreport and the underlying child report.
    The subreport.Report property can then be used to access
    the child report.

    This is demonstrated in the following example:




    var
    lSubReport: TppSubReport;
    lReport: TppChildReport;
    lLabel: TppLabel;
    lDBText: TppDBText;


    begin

    lSubReport := TppSubReport.Create(Self);

    {add to the main report's detail band}
    lSubReport.Band := ppReport1.DetailBand;

    {create the child report (parameters: main report) }
    lSubReport.CreateReport(ppReport1);

    lReport := TppChildReport(lSubReport.Report);

    {assign a datapipeline}
    lReport.DataPipeline := plCustomers;

    {create the default set of bands}
    lReport.CreateDefaultBands;

    lLabel := TppLabel.Create(Self);
    lLabel.Band := lReport.TitleBand;
    lLabel.Caption := 'Customers';

    lLabel.Font.Name := 'Times New Roman';
    lLabel.Font.Size := 24;

    lDBText := TppDBText.Create(Self);
    lDBText.Band := lReport.DetailBand;
    lDBText.DataPipeline := plCustomers;
    lDBText.DataField := 'CustNo';

    lDBText.Color := clYellow;
    lDBText.Font.Name := 'Times New Roman';
    lDBText.Font.Size := 12;



    end;


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2007
    Thank you!

This discussion has been closed.