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

Variable field Calculations.

edited February 2002 in General
Hi All,

We have purchased RB just recently.
I am trying to build a sample report with a particular kind of calculations.
I am using RB 6.03 and Delphi 6.

I have a report which has a "Value" field in detail band. This is fetched
from the database. Then I need another field, "Value PctAge" in the detail
band of the report which has the following calculation:
Value PctAge = (Value/Sum(Value)) * 100, Where Sum(Value) is the sum of the
Value field.

Now this is what I did:
1.) I understand the report needs to be a 2 pass report so I set the
PassSetting to "psTwoPass".
2.) Then I dropped a TppdbCalc field, ValueTotal in the detail band, set the
Datafield to the "Value" field in the database, set the DBCalcType to
"dcSum" and set its "LookAhead" to True.
3.) Then I dropped a TppVariable field in the detail band, set the DataType
to "dtDouble", set the CalcType to "veDataPipelineTraversal".
4.) In the OnCalc event of this field I tried to write the following code:
Value:=ADOQuery1.FieldByName(Value').AsFloat/(ValueTotal.Value) *100, where
ValueTotal is expected to have the total of the "Value" field. But I am
always getting a value of 0;

I am sure this can accomplised quite easily with RB. Any ideas or
suggestions to achieve the above shown calculation are welcome.

Thanks,
Vikram

Comments

  • edited February 2002
    The simplest thing is to add another field into your table, and use the
    table oncalcfields event to do your calculation, then you just use it in RB
    as any other.

This discussion has been closed.