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

ppVariabile & onCalc event & newbie rbuilder developer

edited June 2004 in General
Hi All,
RB7.03 std, WIN2K, D7Ent Upd1
I've placed a ppVariabile named sumVar on the footer of my report to
perform some calculations: i've setted up the following properties:

with sumVar do begin
DataType := dtExtended;
CalcType := veDataPipelineTraversal;
CalcComponent := RowPPl; //this is the pipeline associated with
datafields in the detail band
ResetType := veReportEnd;
end;

In the documentation i've read thai it's better to use the OnCalc event
to perform calculations instead of OnPrint or onGenerate so i've made
this eventHandler

procedure TOrdiniRpt.sumVarCalc(Sender: TObject; var Value: Variant);
begin
inherited;
Value := Value + ppDbText24.FieldValue;
end;

the problem is: sumVarCalc is never executed, an the sumVar displays 0
in the preview.
Can anyone tell me why?
Best Regards
Gianantonio - ITALY

Comments

  • edited June 2004
    Hi Gianantonio,

    Since the sumVar variable is located in the page footer, it's OnCalc event
    will not fire for each record in your dataset. The best way to accomplish
    this is to place another TppVariable inside the Detail band and inside its
    OnCalc event update the value of the subVar variable.

    Note: If you are just calculating simple sums, you might try using a DBCalc
    component. This component will calculate the Sum, Count, Average, Min, or
    Max of a given field in your dataset.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2004
    Hi Nico,
    Thanks for your quick reply.
    I really missed the dbcalc component... it is exactly what i need!
    Thanks for the tip.
    Gianantonio

This discussion has been closed.