SUB Subreports & FindUserObject
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
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
This discussion has been closed.
Comments
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
http://www.digital-metaphors.com
info@digital-metaphors.com
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;
object for the tppSubReport(iObject)
(if iObject.ClassName = 'TppSubReport' then begin ... end)
any help would be appreciated!
thx!
if (aObject is TppSubreport) then
FindTheObject(TppSubreport(aObject).Report);
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
It works...
ppCommunicator :=
TppSubReport(iObject).Report.FindUserObject('DealerLogoBand');
if assigned(ppCommunicator) then ....;
Thanx,
Vincent!