How To…Keep a Running Total in the Header

Question

“How do I keep a running total of the previous page(s) in the header band of the current page being viewed?”

Solution

Place a TppVariable inside the footer band of the report to keep track of the running total until that point.  Then assign that value to a TppVariable located inside the header band of the report.

When a report is printing, each detail band is generated until space on the page runs out.  Once this happens, the engine backs up and prints the last detail band first on the next page.  This detail band however has already been calculated and data traversed causing calculations made on traversal (based on the page) to be one record off.  Using the footer band to keep track of the current page’s totals solves the problem.

Download:  RunningTotalInHeader.zip

Sample Delphi/RAP code: