Example: subreport is used to calculate the total gift amount for each solicitor.

Variable Formula:
WhilePrintingRecords;
Shared CurrencyVar SolTotal;
SolTotal := Sum({Gf_Amount})

If we do not reset this variable back to zero for each solicitor, the previous solicitor's value will remain in the variable.

Reset Formula:
WhilePrintingRecords;
Shared CurrencyVar SolTotal;
SolTotal := 0

Place this new formula in the Report Header section of the subreport.

If you are using a Running Total field for the variable value, check for NULL values:
Variable Formula:
WhilePrintingRecords;
Shared CurrencyVar SolTotal;
if isNull({#RTotal0}) then SolTotal := 0 else SolTotal := {#RTotal0}