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.
I have a vague memory that I'm now having a hard time substantiating about shared variables not passing back up from a subreport. Still looking; good thing it's Friday afternoon.
Edit: I can't find what I was looking for, so a general thought. Check evaluation time, and make sure that the later section on the main report is evaluating after the subreport (WhilePrintingRecords might be your friend here).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With