Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1290
  • Last Modified:

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?
0
DKimzey
Asked:
DKimzey
  • 8
  • 7
  • 3
2 Solutions
 
mlmccCommented:
Add the WhilePrintingRecords to the first formula.

Also when using Crystal format statements should end with a ;

mlmcc
0
 
DKimzeyAuthor Commented:
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.
0
 
jlazanowskiCommented:
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
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
DKimzeyAuthor Commented:
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.  
0
 
jlazanowskiCommented:
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


0
 
DKimzeyAuthor Commented:
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).
0
 
jlazanowskiCommented:
And where is this?

Shared BooleanVar SuppressMainHeader := false
0
 
DKimzeyAuthor Commented:
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.
0
 
jlazanowskiCommented:
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.

0
 
DKimzeyAuthor Commented:
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?

0
 
jlazanowskiCommented:
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
0
 
mlmccCommented:
If the section is suppressed the subreport doesn't run.

The displaying of the value just has to be after the subureport.

Shared is global with the added benefit of sharing with a subreport.  Globals don't share (as I understand it).

mlmcc
0
 
DKimzeyAuthor Commented:
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
0
 
jlazanowskiCommented:
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
0
 
DKimzeyAuthor Commented:
A new page
0
 
jlazanowskiCommented:
This is what I would do. This dosen't really anwser your question, I will need to think more about it but this is the way I would do what you are trying to do.


I would place the page header detail in the approrate group header.

Supress the page header.

Check the new page after box on the header or footer immediatly prior to the execution of the sub-report.

In the subreport check the new page after box in the report footer.

In the subreport section editor for the new page after use the formula not onlastrecord;

The result should be that each group has the page header information, the start a new page for each sub-report, after the sub report start a new page for the group to be printed next.

Justin





0
 
DKimzeyAuthor Commented:
Thank you for your help!
0
 
mlmccCommented:
Glad i could help

mlmcc
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now