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

Relationship between TChildReport and subreport.

edited April 2003 in General
Hi,

Can anyone explain what the relationship is between TppChildReport and
TppSubReport. There seems to be an array Children in TppSubReport which
brings in a TppRelative??

The reason I am asking is I want to get access to objects (TppLabel etc) in
my subreport. The report has been loaded from the database as a RTM file.

At the moment, to access a particular component I am using :

var
iBand : Integer;
iComponentIndex : integer;
ppChildReport : TppChildReport;
begin
if FppReport.ObjectByName(iBand, iComponentIndex, 'ppSubReportDetail')
then
begin
ppChildReport :=
TppChildReport(TppSubReport(FppReport.Bands[iBand].Objects[iComponentIndex])
.Children[0]);

if ppChildReport.ObjectByName(iBand, iComponentIndex,
'ppDetailTitleLbl') then
(ppChildReport.Bands[iBand].Objects[iComponentIndex]).Visible :=
False;

end;


This seems to work BUT is this the right way???

TIA
Sham.

Ps. At the moment I am still evaluating the Demo version of RB which does
not come with any help files.
If there is any other resources out there which can help me, please let me
know.
Also, thanks for all the fast feedback. An excellent product and hopefully
by the end of this week we
will buy the full D6 version of RB.

Comments

  • edited April 2003
    Sham,

    TppSubReport is a descendent of the TppComponent class and was created so
    you can place a subreport component inside an existing report.
    TppChildReport is a descendent of TppCustomReport and is contained inside
    the TppSubReport component. TppChildReport and TppReport are very similar.
    The main difference between a child report and standard report is the
    printing behavior. The child report generates when the subreport component
    generates. The child report does not contain a cache manager or publisher
    object, but relies on the subreport component to handle the communications
    which these objects normally provide.

    You are going to want to use a Report Object Loop to access the components
    of a subreport. Once you locate the subreport, you can use the
    TppSubreport.Report property to access the ChildReport. Then you can
    recursively call the object loop passing TppSubReport.Report in order to
    locate the component you need from the subreport. Below is a small example
    of how this could be done.

    procedure RetrieveComponent(aLabel: TppLabel; aReport: TppCustomReport);
    var
    liBand: Integer;
    liObject: Integer;
    lObject: TppComponent;
    begin

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

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

    if (lObject is TppSubReport) then
    RetrieveComponent(aLabel, TppSubReport(lObject).Report)
    else if (lObject = aLabel) then
    TppLabel(lObject).Visible := false;

    end;
    end;
    end;





    --
    Best Regards,

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