tppvariable on calc event
I have a subreport inside a region, the region keeptogether is true, inside
the subreport is a tppvariable, in the oncalc event I perform some
calculation, but I find that the oncalc event will fire more than one if the
subreport content will span a page, I think this is due to region
keeptogether property.
So how to control oncalc event only fire once for each record?
the subreport is a tppvariable, in the oncalc event I perform some
calculation, but I find that the oncalc event will fire more than one if the
subreport content will span a page, I think this is due to region
keeptogether property.
So how to control oncalc event only fire once for each record?
This discussion has been closed.
Comments
This seems to be a special case. You might try adding a condition that
checks the current record value and compares it to the last record value the
last time the event was fired. If the value is different, make the
calculation, if not, skip it. Something like the following...
FOldValue: Integer;
procedure TForm.VariableCalc(Sender: TObject; Value: Variant);
var
lCurrentValue: Integer;
begin
lCurrentValue := Report.DataPipeline['KeyField'];
if FOldValue <> lCurrentValue then
begin
//DO CALCULATIONS
FOldValue := lCurrentValue;
end;
end;
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico:
Is this a bug? If I understand it right, it sure seems to be.
Ed Dressel
After further research, I am unable to recreate this issue. I created a
report with a stretchable region and a subreport inside the region. Both
the region and subreport have their KeepTogether properties set to True.
Inside the subreport, I have a TppVariable and make a calculation in its
OnCalc event. This never causes the OnCalc to fire more than once per
traversal, even when the page breaks.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Okay, had me scared for a second.
Ed Dressel