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

Access subreport in delphi

edited September 2006 in General
Hi

I am trying make a subreport visible or invisible before printing a report.
The template has 7 subreports and I need to access the properties of
subreport7.

If I knew in advance which template the user was going to load, I could use
.subreport7.Visible := false,
but this won;t compile because delphi knows nothing about subreport 7.
Is there a method like ppReport.Subreport[6] , then I can use Try..Except to
get at it ?

Thanks
Andy Dyble

Comments

  • edited September 2006
    Hi Andy,

    Once the subreport is loaded, you can perform a report object loop to locate
    the subreport you are after. Take a look at the following article on
    creating a report object loop.

    ----------------------------------------------
    Tech Tip: Loop Thru All Objects in a Report
    ---------------------------------------------

    A ReportBuilder report is composed of a set of components. The basic
    structure is

    Reports.Bands[].Objects[]

    The bands and objects within the report can be accessed directly by object
    name or via the Bands and Objects array properties.

    Below is an example of using the Bands and Objects array properties to
    change the font for all objects on a report.


    uses
    ppClass;


    procedure AssignFontToReport(aFont: TFont; aReport: TppCustomReport);
    var
    liBand: Integer;
    liObject: Integer;
    lObject: TppComponent;

    begin

    for liBand := 0 to aReport.BandCount-1 do

    for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
    begin
    lObject := aReport.Bands[liBand].Objects[liObject];

    if lObject.HasFont then
    lObject.Font := aFont;

    end;

    end;


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