Clearing a report ??
Hi
I have a report ( ppReport ) and wish to use it several times within the
application. I wish to use it and then wipe it back to just a Header, Body
and Footer with nothing in and no groups....
I have tried :-
for i := 0 to ppReport.BandCount -1 do
begin
for c := 0 to ppReport.Bands[i].ObjectCount -1 do
begin
ppReport.Bands[i].Objects[c].Free;
end;
end;
.. but it keeps failing. I have tried several others such as .Reset, but
none seems to work. Do you have any suggestions.
Thanks
Tony Danby
I have a report ( ppReport ) and wish to use it several times within the
application. I wish to use it and then wipe it back to just a Header, Body
and Footer with nothing in and no groups....
I have tried :-
for i := 0 to ppReport.BandCount -1 do
begin
for c := 0 to ppReport.Bands[i].ObjectCount -1 do
begin
ppReport.Bands[i].Objects[c].Free;
end;
end;
.. but it keeps failing. I have tried several others such as .Reset, but
none seems to work. Do you have any suggestions.
Thanks
Tony Danby
This discussion has been closed.
Comments
The reason this is failing is that when you free an object, ReportBuilder is
notified of this and automatically updates the Band.ObjectCount for the
current band. For instance if you had two objects in a band and use the
loop you have below, the second you free the first object, the object left
in the Objects list now has an index of 0, not 1 as the loop expects. You
will need to use a while loop instead of a for loop so you can chang the
index number on the fly.
Of course the best way around this problem would be to save your reports as
template files (.rtm) and load the templates on the fly in code. Then
ReportBuilder will take care of clearing out the old report as it loads a
completely new report that was saved to file.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com