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

accessing component names after loadfromdatabase

edited March 2007 in End User
Dear all,
I use Loadfromdatabase to pull in a user defined template.
This is linked to a database pipeline.
In some labels there is a TppShape component that is coloured based on the
colour code in the database record.
I wanted to do something like:

for i:=0 to ppreport3.ComponentCount-1 do //ppreport3 is
the "empty" report component into which I have loaded the template
if ppreport3.Components[i] is Tppshape then
if datamod.qStkrecLabColour.AsString <> '' then
Tppshape(ppreport3.Components[i]).Brush.Color:=StringToColor('cl' +
trim(datamod.qluStkrecLabColour.AsString));


the component count for ppReport3 is coming out as 3, and none of them
Tppshape. I have tried ppreport3.template.report.ComponentCount-1 (=3)
and ppreport3.detailband.ComponentCount-1 (=0)

How can I do what I want, to dynamically change the colour of a shape (with
an unknown name) based on the pipeline datasource?

kind regards

John

Comments

  • edited March 2007

    The report composite is structure like this...

    Report.Bands[ ].Objects[ ]

    where Report.BandCount and Band.ObjectCount return the number of items in
    the respective array properties. See the CodeBased thread of the Tech Tips
    newsgroup for an example of iterating over the elements in a report.

    Each of the elements that comprise the report (Band, Shape, DBText, etc)
    have a UserName property that you can set - this is the name that is
    displayed inside the report designer and is used by RAP code. You can call
    the Report.FindUserObject(aUserName: String): TppCommunicator and then
    typecast the result.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited March 2007
    Dear Nard,
    many thanks, works a treat.

    regards

    John

This discussion has been closed.