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

print a certain subreport page once, other subreports variable times

edited June 2006 in General
?i have report with 4 subreports. The user can give in the number of
copies the documents must printed. The first three subreports must be
printed according to the number that was given by the user but the 4th
subreport must ALWAYS be printed one time !
How can i do this?



--- posted by geoForum on http://delphi.newswhat.com

Comments

  • edited June 2006
    Hi Rezza,

    I'm a bit unclear about what you would like your report to look like. If
    for instance the user gives the number "2". Do you want your report to look
    like the following?

    Subreport 1
    Subreport 1
    Subreport 2
    Subreport 2
    Subreport 3
    Subreport 3
    Subreport 4

    Is this a master detail report? Where are these subreports located in the
    main report? Are they child subreports?


    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2006
    Hi Nico,

    Yes this is the way i want the report to look like.
    The subreports are childreports.


    If
    look
    the



    --- posted by geoForum on http://delphi.newswhat.com
  • edited June 2006
    Hi Rezza,

    Unfortunately there is no built-in feature to accomplish this however it
    should be possible by dynamically creating subreports at runtime as you need
    them. As a starting point, I would create your 4 subreports from scratch
    and save each of them as template files (.rtm). Then based on what number
    your users give you, dynamically create the number of subreports you need
    (for example if they say "2", you would create 7 subreports) and load the
    proper templates into each subreport. Take a look at the tech-tip below on
    how to create subreports at runtime.

    -------------------------------------------------
    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;


    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.