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

tppvariable on calc event

edited March 2004 in General
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?

Comments

  • edited March 2004
    Hi,

    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;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2004
    > This seems to be a special case.

    Nico:

    Is this a bug? If I understand it right, it sure seems to be.

    Ed Dressel
  • edited March 2004
    Hi Ed,

    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.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2004
    > After further research, I am unable to recreate this issue.

    Okay, had me scared for a second.

    Ed Dressel
This discussion has been closed.