How To…Show a Total in the Last Detail

Question

“How can I show the sum of the previous details in the last detail band of a group, rather than using the group footer or footer band?”

Solution

This can be done by making the calculation in a TppVariable, then manually adding a DrawCommand to the page aligned with the last detail band of each group.  Start by placing an invisibile TppVariable on the report to make the calcuation.  Implement its OnCalc event to calculate the sum of the group.  Next call a routine in the FooterBand.BeforePrint event that creates a DrawText command and assign the value of the variable to its value.  Finally position the DrawText command to the point on the page where the last detail band was printed.

Download:  GroupSumInLastDetail.zip

Sample Delphi code: