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

Strange error finding labels.

edited May 2003 in General
Hi,

I have found something strange and had to do a work around. Basically on my
report which is loaded from an RTM file in a database,
I have a Region component (ppHeaderTitleRegion) which has 3 labels on. The
first two labels can be found by using ObjectByName
but the last one cannot. Below is the work around that I used to.

Why is this happening?

Sham.

procedure TReportTitleMapper.SetReportLabelsForHeader(const pppReport:
TppReport; const pSummaryDetailsXMLHandler: TSummaryDetailsXMLHandler);
var
iBand : integer;
iComponent : integer;
j : integer;
Region : TppRegion;
begin
if pppReport.ObjectByName(iBand, iComponent, 'ppTitleHeaderLblOnHeader')
then
TppLabel(pppReport.Bands[iBand].Objects[iComponent]).Caption :=
pSummaryDetailsXMLHandler.ReportHeader;

if pppReport.ObjectByName(iBand, iComponent, 'ppRunOnLblOnHeader') then
TppLabel(pppReport.Bands[iBand].Objects[iComponent]).Caption :=
pSummaryDetailsXMLHandler.ReportRunDate;

// DOES NOT WORK???
// if pppReport.ObjectByName(iBand, iComponent, 'ppCopyRunTime') then
// TppLabel(pppReport.Bands[iBand].Objects[iComponent]).Caption :=
pSummaryDetailsXMLHandler.ReportRunTime;

// WORK AROUND---
if pppReport.ObjectByName(iBand, iComponent, 'ppHeaderTitleRegion') then
begin
Region := TppRegion(pppReport.Bands[iBand].Objects[iComponent]);

for j := 0 to Region.ObjectCount - 1 do
begin
if Region.Objects[j].Name = 'ppCopyRuntime' then
TppLabel(Region.Objects[j]).Caption :=
pSummaryDetailsXMLHandler.ReportRunTime;
end;
end;

end;

Comments

  • edited May 2003
    Sham,

    The reason you are not finding the last label using the ObjectByName method
    is probably due to a naming conflict. For this (among others) reason, we
    always recomend using a report object loop to find components in a report.
    Your workaround method is essentially using a report object loop to find the
    last label in the region. I would recommend using this method to find all
    three labels in the region. Check out the tech-tips | Code Based | Loop
    Thru All Objects in a Report thread for more information on this method.

    --
    Best Regards,

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