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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BooleanVar Conundrum 1

Status
Not open for further replies.

CoffeeManOhYesIAm

Technical User
Feb 17, 2005
21
0
0
US
Good day all, here's a weird little problem that I've just run across:

I've got a subreport (in Main Report, Details B) that has a formula in its details section. It's the formula's job to determine if SPC charts need to be printed in the main report's Details H section. If they do, a shared variable for suppressing Details H is set to False, and a message appears that identifies the SPC chart requirement. If they are not required, the shared variable is set to True, and another related message is printed.

The formula is:
Code:
[green]// @Analysis Code[/green]

[blue]shared booleanVar[/blue] DHsuppress;
[blue]shared numberVar[/blue] x;

[blue]if[/blue] {JobOper.OprSeq} = x [blue]AND trimleft[/blue]([blue]trim[/blue]({JobOper.AnalysisCode})) = "SPC" 
[blue]then[/blue] 
(
 DHsuppress := [blue]False[/blue]; [green]// show spc chart[/green]
 "*** SPC Charts are required at this operation. ***" + [blue]chr[/blue](13) + 
 "Value of DHsuppress is:  " + [blue]ToText[/blue](DHsuppress);  )
[blue]else[/blue] 
(
 DHsuppress := [blue]True[/blue];  [green]// suppress spc chart[/green]
 "For more frequent measurements, attach an SPC chart.";)
Notice that I've added a debug message to the formula that reports the value of the shared variable DHsuppress. When the main report is previewed for a record that requires SPC charts, the subreport displays:

*** SPC Charts are required at this operation. ***
Value of DHsuppress is: False​

Further down in the main report, Details H contains a subreport displaying the SPC chart. That's not the issue of this post, but it is important to note that the Format Section, Suppress X-2 formula for Details H states:
Code:
[green]// Details H.  Suppress X-2[/green]
[blue]Shared booleanVar[/blue] DHsuppress;

[blue]if[/blue] (DHsuppress = [blue]True[/blue])
[blue]then
 True
else
 False[/blue]
So hopefully by now you can guess where this is going. It just so happens that when the main report is previewed for a record requiring SPC charts, the Details B subreport outputs:

*** SPC Charts are required at this operation. ***
Value of DHsuppress is: False​

But strangely, the Details H section is getting supressed!

I added another debug formula to the Details C section to determine the value of shared variable DHsuppress which goes like this:
Code:
[green]// @Value of DHsuppress.[/green]

[blue]shared booleanVar[/blue] DHsuppress;

"Value of DHsuppress is:  " + [blue]ToText[/blue](DHsuppress);
And when the main report is previewed (for the same test record) this formula displays:

Value of DHsuppress is: True​

So what gives??

How is the value of the shared DHsuppress variable magically changing from False to True?

I'd be grateful for any explanations.

Thanks,

CMoyia

---Technical Information:
Crystal 8.5
Progress DB
ODBC connectivity
-------------------------
 
Simpliofy this:

// Details H. Suppress X-2
Shared booleanVar DHsuppress;
if (DHsuppress = True)
then
True
else
False

to just

Shared booleanVar DHsuppress

it's the same thing

From the indicators here, I don't understand why it should be changing, so there are likely other factors at play here.

Note that for any row which does not have a link in the subreport, your variable will retain it's last known value, the formula will NOT fire. Most will reset this formula at some logical point, perhaps in a details I section.

-k
 
Hey thanks for the simplifying tip...I always like to get rid of clutter.

As for the logic problem, you are right! My subreport does fire for rows that are getting suppressed by its own details X-2 formula. Since there are records after the one with the SPC requirement that do not have this requirement, they are triggering the "else" path of the conditional statement which of course sets my shared variable to True.

Dang. I should have continued debugging that formula with a debug statement in the else path. :-D

Thanks for the insight, SV!
You deserve a STAR.

-Geo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top