Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shared variable is one page behind...

Status
Not open for further replies.

JCruz063

Programmer
Feb 21, 2003
716
US
Guys,
Crystal 10.
I have a report with a group. In the footer of that group, I have a subreport. The subreport does some calculations and updates a shared variable.

I want to suprress or display the subreport based on the value of the shared variable. To do that, I'm trying to suppress or display the footer of the group (because that's where the subreport). So, for the footer, I have:
[tt]
shared numbervar x;
if x = 0 then
true;
else
(
x := 0;
false;
)[/tt]

The point is this: if the shared variable is 0, the subreport should not be visible, and thus I must hide the footer of the group in the main report.

The problem is that x seems not to be updated until the next group is printed. In other words, let's say that for the first value in the group, the subreport set x to 50. In the group footer, x appears to be 0, not 50. When the next page (next group value) comes along, x appears as 50 in the group footer. Thus, x is always one group value behind.

I tried iserting another footer section in the in the main report, and bang... in footer b section, I see the correct value of x, but in the footer a, which is where the subreport is, x has the wrong value. I tried evaludateafter, and that didn't work. I also tried, calling a formula in footer b FROM footer a, to see if I got the right value and no luck.

How can I get the updated value so that I could display/suppress the subreport based on x?

Thanks.

JC

_________________________________
I think, therefore I am. [Rene Descartes]
 
Never mind guys,
I'll suppress the subreport within the subreport itself.

Thanks!

_________________________________
I think, therefore I am. [Rene Descartes]
 
That's best. Note that shared variables can only be used in the main-report section below the section that calls the subreport. They're the last thing to be calculated in any given section.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top