Subtotals
I'm trying to accumulate Double values as they print in a detail line to
later print subtotals in a group footer. Unfortunately, placing the
code to accumulate these totals in events like BeforePrint and
AfterPrint seems to be giving me unpredictable results.
Taking the simple case, I have a global variable X and each time a
detail line is printed, I want to add the content of a database value
(for example, Trx['UCount']) to it, then print the subtotal in the group
footer, zero the global variable X, and start the process over.
So, I'm trying to determine which events are the correct places to (a)
accumulate the total, and (b) zero it after printing. Also, any
additional traps I may need to look out for (I noticed remarks on
setting static band height, which I tried but didn't make any difference).
To me, the obvious places are the BeforePrint and AfterPrint handlers
for the detail band, but that yields strange results as one pages
through the report. This is on an older version (6.x), and I don't work
with this particular product routinely, so I'm struggling. Any guidance
is appreciated.
DR.
later print subtotals in a group footer. Unfortunately, placing the
code to accumulate these totals in events like BeforePrint and
AfterPrint seems to be giving me unpredictable results.
Taking the simple case, I have a global variable X and each time a
detail line is printed, I want to add the content of a database value
(for example, Trx['UCount']) to it, then print the subtotal in the group
footer, zero the global variable X, and start the process over.
So, I'm trying to determine which events are the correct places to (a)
accumulate the total, and (b) zero it after printing. Also, any
additional traps I may need to look out for (I noticed remarks on
setting static band height, which I tried but didn't make any difference).
To me, the obvious places are the BeforePrint and AfterPrint handlers
for the detail band, but that yields strange results as one pages
through the report. This is on an older version (6.x), and I don't work
with this particular product routinely, so I'm struggling. Any guidance
is appreciated.
DR.
This discussion has been closed.
Comments
The BeforePrint and AfterPrint events are not guaranteed to only fire once
per traversal. The only event that you should make calculations such as
sums is the TppVariable.OnCalc event. Placing a TppVariable on a report and
setting it to calculate on Traversal will fire the OnCalc event once per
detail. See the following article on the fundamentals of calculations in
ReportBuilder.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Calculations/Overview
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com