Running balance calculation
I am building a statement report.
1) It groups on and starts a new page for each customer
2) The report is laid out as follows
Customer 1
Balance Forward: $100
Description Amount Running Balance
-----------
Purchase 1 $50 $150
Purchase 2 $70 $220
Payment -$20 $20
etc.
What is the best way to calculate the running balance. I have been using
either the on before printer header or on before generate header events
to recognize when to incorporate the initial balance forward amount into
the running balance(to get $150 in this example) but it is giving me
inconsistent results. Seemingly these events don't always fire.
Tony Peppercorn
1) It groups on and starts a new page for each customer
2) The report is laid out as follows
Customer 1
Balance Forward: $100
Description Amount Running Balance
-----------
Purchase 1 $50 $150
Purchase 2 $70 $220
Payment -$20 $20
etc.
What is the best way to calculate the running balance. I have been using
either the on before printer header or on before generate header events
to recognize when to incorporate the initial balance forward amount into
the running balance(to get $150 in this example) but it is giving me
inconsistent results. Seemingly these events don't always fire.
Tony Peppercorn
This discussion has been closed.
Comments
All calculations should be made in the OnCalc event of a TppVariable.
This is the only event that is designed to fire only once per traversal.
Take a look at the following articles on making calculations inside a
report and keeping a running balance.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Calculations/Overview
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Calculations/How_To...Keep_a_Running_Total_in_the_Header
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com