Link to home
Start Free TrialLog in
Avatar of DKimzey
DKimzey

asked on

Shared Variable Not Working

In a Crystal Report I am developing, I have a Main Report and a Sub-Report.  

In the Main Report, I have a formula called SetMainHeaderOn

Shared BooleanVar SuppressMainHeader := false

This formula has been placed in a header section that fires before the section containing the sub-report.

In the Sub-Report, I have a formula called SetMainHeaderOff

WhilePrintingRecords;
Shared BooleanVar SuppressMainHeader:=true

In the Main Report - I use a formula ShowMainHeader

WhilePrintingRecords;
Shared BooleanVar SuppressMainHeader

However, ShowMainHeader always returns false.  If I place a similar query in the sub-report, it is always true.  Any ideas?
Avatar of Mike McCracken
Mike McCracken

Add the WhilePrintingRecords to the first formula.

Also when using Crystal format statements should end with a ;

mlmcc
Avatar of DKimzey

ASKER

mlmmc,

Thanks - but no effect.

I modified the formulas as follows:

In the Main reports:

SetMainHeaderOn
---------------------
WhilePrintingRecords;    // Note that without the semi-colon - you will get a "The remaining text dos not appear to be part of the formula" error message
shared BooleanVar SuppressMainHeader := false;


ShowMainHeader
--------------------
WhilePrintingRecords;
shared BooleanVar SuppresMainHeader;


In the Sub-Report

SetMainHeaderOff
---------------------
WhilePrintingRecords;
share BooleanVar SuppressMainHeader := true;

ShowMainHeader always returns false even on pages which are nothing but the sub-report.
I am not 100% sure on this but I could have sworn I read somewhere that to share variables with subreports you need to declare them global. You might give that a try
Avatar of DKimzey

ASKER

J Lazanowski,

Thank you -- but no effect.  If I show the value in the Sub-Report, it is true.  Simultaneously if I display the value in the Main Header, it is false.  
I just looked it up and my book your it does need to be a shared variable.

where is this formula located

WhilePrintingRecords;
Shared BooleanVar SuppressMainHeader


Avatar of DKimzey

ASKER

The report has four group levels.  The first three and the detail line are suppressed, so I dropped it on the group4 footer (the first non-suppressed line).
And where is this?

Shared BooleanVar SuppressMainHeader := false
Avatar of DKimzey

ASKER

J Laznowski,

Correct me if I am mistaken, but I beleive the problem is we need to query the shared variable at the correct group level or else I will see what I am seeing now.  So the question is:

At what level in the Main report should we query the shared variable in order to have the desired result.  Or -- what group level should be used in the main report to query the shared variable so that it synchronizes with the sub-report.
That is what it looks like to me. What I am trying to assertain is where you need this sub-report and where you do not.

If you are setting the shared variable to false in the header before the level the sub-report is shown then it seems to me that you will always get a false return, unless you are running the sub-report on that level everytime.

I guess my question would be what are you trying to do and what are the desired results.

Avatar of DKimzey

ASKER

The real question is then:

If my sub-report always fires in the main report at group footer 2, what group level in the main report would pickup changes to a shared variable in the subreport or -- what main report group levels fire while a potentially multi-page sub-report is running?

I belive that main reporting execution is haulted while the sub-report is computed. Therefore nothing else in the main report would be executed until the sub report is finished processing.

I am still trying to understand what you are doing.

You set a variable false in a header before the sub-report is fired. In the sub-report you set the variable to true, what is the purpose. If the sub-report always runs?

Justin
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DKimzey

ASKER

Justin,

Sorry -- what I want to do is suppress the main report page header when I am in the sub-report. I almost need a  ProcessingSubReport flag.

-Doug
Ok just so I am clear.

You have a main report. You want to have a sub-report that processes and does not show the main report header on the same page.

Your sub-report always runs? i.e. it's not suppresed on any condition? Do you want your sub-report detail to start on the same page as your main report or on a new page?

Justin
Avatar of DKimzey

ASKER

A new page
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DKimzey

ASKER

Thank you for your help!
Glad i could help

mlmcc