Question
“How do I display totals calculated inside a subreport in my main report?”
Solution
Delphi:
Update the main report variables directly inside the OnCalc event of a variable inside your subreport.
RAP:
- Declare a global TppVariable from the Module view inside the code workspace (RAP).
- Set the global variable equal to a TppVariable in the main report.
- Update the value of the global variable inside the subreport (similar to Delphi code). This will in turn update the value of the variable placed in the main report.
Download: TotalsFromSubReport.zip
TotalsFromSubReportWithRAP.zip
RunningPageTotalFromSubreport.zip
Sample Delphi code:
1 2 3 4 5 6 |
procedure TForm1.ppVariable2Calc(Sender: TObject; var Value: Variant); begin //ppVariable1 is located inside the main report. ppVariable1.Value := ppVariable1.Value + ppSubReport1.Report.DataPipeline['AmountPaid']; end; |
Sample RAP Code:
Global Declarations…
1 2 |
var varMainPageTotal: TppVariable; |
Global Events…
1 2 3 4 5 6 |
procedure GlobalOnCreate; begin //Variable1 is on the main report. varMainPageTotal := Variable1; end; |
Subreport…
1 2 3 4 5 |
procedure SummaryAfterGenerate; begin //This will update Variable1.Value. varMainPageTotal.Value := varMainPageTotal.Value + DBCalc1.Value; end; |