calculation
Please, how can I get the value of a DBCALC variable to easily make
crossed references of dbcalc field variables (sum, average, etc.) into
another varible:
A simple example: I put a variable "Var1" on a foot group to sum the
values of two DBCalc field variables:
procedure Var1OnCalc(var Value: Variant);
begin
a) Value := DBCalcFIELD_A.VALUE+(DBCalcFIELD_B.VALUE); it does not
work because returns the sum of all printed values of the
field_a+field_b in the detail band. b) Value :=
DBCalcFIELD_A.FIELDVALUE+DBCalcFIELD_B.FIELDVALUE; it does not work
either because returns the sum of the last printed value of the
field_a+field_b in the detail band.
end;
What must I do ?
Thanks
Angel
crossed references of dbcalc field variables (sum, average, etc.) into
another varible:
A simple example: I put a variable "Var1" on a foot group to sum the
values of two DBCalc field variables:
procedure Var1OnCalc(var Value: Variant);
begin
a) Value := DBCalcFIELD_A.VALUE+(DBCalcFIELD_B.VALUE); it does not
work because returns the sum of all printed values of the
field_a+field_b in the detail band. b) Value :=
DBCalcFIELD_A.FIELDVALUE+DBCalcFIELD_B.FIELDVALUE; it does not work
either because returns the sum of the last printed value of the
field_a+field_b in the detail band.
end;
What must I do ?
Thanks
Angel
This discussion has been closed.
Comments
Use the TppVariable rather than the TppDBCalc.
Here are some guidelines for using TppVariable.
a. Set the Variable.DataType
b. Code the calculations using the Variable.OnCalc event.
c. Use the Timing dialog to control the timing of the OnCalc event.
To access the Timing dialog, right click over the Variable
component and select the Timing... option from the speed menu.
d. Set the LookAhead property to True, when you need to display
summary calculations in the title, header, group header, etc.
e. To perform calculations based on the results of other
calculations use the Calc Order dialog of the band. To access
the Calc Order dialog, right click over the Band component
and select the Calc Order... option from the speed menu.
By using TppVariable components ReportBuilder will take care of caching
intermediate results of accumlated calcs that cross pages.
There are a number of calculation examples in the main demos.dpr
project.
---
Additional Notes:
1. Do NOT use Band.BeforePrint or Band.AfterPrint. These events fire
multiple times and therefore should not be used for calculations.
2. Do NOT store results in variables that exist outside of the reports.
For example - form level variables.
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com