Home Subreports

SUB Subreports & FindUserObject

edited June 2003 in Subreports
Hi!
Here at work we have some reports having a standard logo with
shopinformation. The logo is loaded using a stream from an independ
tppsubreport to the subreport from the loaded report. This works fine. using
the folowing code.
(
if trim(aSubReportName) <> '' then begin
ppCommunicator := ppReport.FindUserObject('DealerLogoBand');
if Assigned(ppCommunicator) then begin
try
MemStream := TMemoryStream.Create;
ppSubReport.Template.SaveToStream(MemStream);

TppSubReport(ppCommunicator).Report.Template.LoadFromStream(MemStream);
TppSubReport(ppCommunicator).Report.PrintToDevices;
finally
FreeAndNil(MemStream);
end;
end;
end;
)

Now the problem starts when i have a subreport on a subreport. I cant find
the subreport anymore.
I have a report with 3 subreports. Each of those 3 subreports contains, in
there header, a subreport with some shopdata.

How can i dynamicaly assign data to the logo at runtime?

Any help is welcome. thx.Fin

Comments

  • edited June 2003
    Instead of calling FindUserObject, try using a report object loop where you
    recursively call the find method by passing Subreport.Report as the
    parameter. There is a tech-tip on this in the tech-tips newsgroup in the
    code based thread.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited June 2003
    Hi, thx for the responce.

    I tried folowing but no result... (halfways implemented the FindUserObject..
    I'm searching ....

    var
    lBand : tppBand;
    idBand : integer;
    idBandCount : integer;

    iObject : TppComponent;
    idObject : integer;
    idObjectCount : integer;

    irObject : TppComponent;
    idrObject : integer;
    idrObjectCount : integer;


    idBand := 0;
    idBandCount := ppReport.BandCount;
    while (idBand < idBandCount) do begin
    lBand := ppReport.Bands[idBand];
    idObject := 0;
    idObjectCount := lBand.ObjectCount;
    while idObject < idObjectCount do begin
    iObject := lBand.Objects[idObject];
    if iObject.ClassName = 'TppSubReport' then begin
    ppCommunicator := nil;
    for idrObject := 0 to iObject.ComponentCount -1 do begin
    if iObject.Components[idrObject].ClassName = 'TppSubReport'
    then begin
    ppCommunicator :=
    TppSubReport(iObject.Components[idrObject]).FindUserObject('DealerLogoBand')
    ;
    if Assigned(ppCommunicator) then begin
    try
    MemStream := TMemoryStream.Create;
    ppSubReport.Template.SaveToStream(MemStream);

    TppSubReport(ppCommunicator).Report.Template.LoadFromStream(MemStream);
    TppSubReport(ppCommunicator).Report.PrintToDevices;
    finally
    FreeAndNil(MemStream);
    end;
    end;
    end;
    end;
    end;
    inc(idObject);
    end;
    inc(idBand)
    end;



  • edited June 2003
    I can find the subreports of the report , but i dont know how to get the
    object for the tppSubReport(iObject)
    (if iObject.ClassName = 'TppSubReport' then begin ... end)

    any help would be appreciated!
    thx!

  • edited June 2003
    This is the recursive call in a routine

    if (aObject is TppSubreport) then
    FindTheObject(TppSubreport(aObject).Report);

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited June 2003
    Great!!!!

    It works...

    ppCommunicator :=
    TppSubReport(iObject).Report.FindUserObject('DealerLogoBand');
    if assigned(ppCommunicator) then ....;


    Thanx,
    Vincent!

This discussion has been closed.