Home RAP

Global Variable not showing up in calculations

edited November 2010 in RAP
Hi,

I have a report with a subreport. I have gotten the subreport total to print
on the main report using the tutorial in rbwiki. The problem is, I now need
to perform additional calculations using that total on my main report and
the results of those additional calculations are always coming back as zero.
The subreport and the calculations on the main report are all in the detail
band.

Main report:

Global-Declarations-Variables

gGrossPay : TppVariable;

Global-Events-OnCreate

Variable2 := gGrossPay
--- This variable is calculate on transversal, reset on groupend.

Subreport:

Variable24OnCalc (var Value : Variant);
begin
Value := Value + HISTORY['AMOUNT'];
gGrossPay := gGrossPay + HISTORY['AMOUNT'];
end;

The correct total prints on the report in Variable2. What I am not able to
do is reference this total in any other formulas on the main report. For
example:

Variable11OnCalc (var Value : Variant);
begin
Value := gGrossPay.Value * 0.062;
end;

Variable11OnCalc (var Value : Variant);
begin
Value := Variable2.Value * 0.062;
end;
--- This not only returns 0 for the calcuation, but Variable2 now displays
zero as well.

Comments

  • edited November 2010
    Hi Steven,

    This is most likely a timing issue. The OnCalc of the variable is firing
    before the value of the global variable has been up dated. You can work
    around this by making the separate calculation inside the subreport
    variable's OnCalc event similar to the way you are making the first
    calculation (with another global variable).

    gGrossPay: TppVariable;
    gGrossPayTax: TppVariable;

    Variable2 := gGrossPay;
    Variable11 := gGrossPayTax;

    Variable24OnCalc (var Value : Variant);
    begin
    Value := Value + HISTORY['AMOUNT'];
    gGrossPay := gGrossPay + HISTORY['AMOUNT'];
    gGrossPayTax := gGrossPay * 0.062;
    end;


    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.