I have a formula @InitVars in the page header which includes the following, and similar lines:
shared numbervar runWaste:=0;
In Details v, I have a sub-report, which has a formula @SetRunWaste:
shared numbervar runWaste;
if (OnFirstRecord) then
(
if not(isnull({x.x-or})) and
not(isnull({x.y-override})) and {x.y-override} = true then
runWaste:={x.x-or}
else
runWaste:= {x.x}
);
runWaste
I can see the output of this formula in the sub-report is 18.00.
However, both in another sub-report, in Details az, and in the main report in Details w (as a test), I have the following formula @test:
shared numbervar runWaste;
runWaste;
In both places, it shows as 0.00.
Why is it showing 0 not 18?
I’m using Crystal Reports version 11.0.0.895.
The problem is that @InitVars is in the page header, not the report header. It is resetting the variable to 0 at the top of every page.
Moving @InitVars to the report header fixed it so the correct number comes up in the sub-report in Details az.
I still see some odd behavior when I include the variable in the main report, but since that was just for debugging, not the main target, I don’t care.