Adding a subreport total to main report total

edited August 2015 in RAP
Hello,

Using ReportBuilder enterprise, version 16.02 and Delphi XE7.

I have an accounting type of report with a subreport.

The report's format is like this:

Group header: beginning balance
Detail rows: subreport showing multiple detail rows
Group footer: ending balance

The ending balance = beginning balance + total of detail rows from
subreport.

What I have done:
On the main report's group footer I placed two report variables named
vrRunningBalance, vrEndingBalance.

I created a global variable: gRunningBalance.

On the global oncreate event: gRunningBalance := vrRunningBalance;

In the subreport, I placed a variable Variable1 on the detail row.

This variable's onCalc event:
gRunningBalance.value := gRunningBalance.value +
plSecondaryReportDataset['AMOUNT'];
value := gRunningBalance.value;

In the variable vrEndingBalance on calc event:
Value := plReportDataset['BEGINMONTHBALANCE'] + gRunningBalance.value;

Everything works as desired except for the ending balance. When I run
the report, the ending balance is has the beginning balance value.

the variable vrRunningBalance does correctly print the running balance
value from the subreport. But it is not adding it into the ending
balance total.

What am I missing? Thanks for your help.
Phil Horst

Comments

  • edited August 2015
    On 08/29/2015 5:32 PM, Phil Horst wrote:

    Followup - I ended up solving this using SQL, but I would still like to
    know how to make this work with Reportbuilder.

    Thanks,
    Phil
  • edited August 2015
    Hi Phil,

    The issue is the timing of when the OnCalc event of the vrEndingBalance
    variable fires and the Variable1 variable. My guess is that if you
    trace into the calc code for vrEndingBalance, gRunningBalance is 0.

    You will need to update both variables outside the subreport from inside
    the subreport (Variable1.OnCalc). The easiest way would be to create an
    other global variable for the ending balance.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2015
    On 08/31/2015 10:04 AM, Nico Cizik (Digital Metaphors) wrote:

    Hi Nico,

    Yes, that's exactly what I needed to know. Making this adjustment
    resolves the problem.

    Thanks,
    Phil
This discussion has been closed.