?
Solved

Shared Variable Not Working

Posted on 2005-03-14
18
Medium Priority
?
1,241 Views
Last Modified: 2007-12-19
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
Comment
Question by:DKimzey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 3
18 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 13541097
Add the WhilePrintingRecords to the first formula.

Also when using Crystal format statements should end with a ;

mlmcc
0
 

Author Comment

by:DKimzey
ID: 13543924
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
 
LVL 1

Expert Comment

by:jlazanowski
ID: 13545405
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 

Author Comment

by:DKimzey
ID: 13545512
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
 
LVL 1

Expert Comment

by:jlazanowski
ID: 13545582
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
 

Author Comment

by:DKimzey
ID: 13545646
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
 
LVL 1

Expert Comment

by:jlazanowski
ID: 13545708
And where is this?

Shared BooleanVar SuppressMainHeader := false
0
 

Author Comment

by:DKimzey
ID: 13545886
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
 
LVL 1

Expert Comment

by:jlazanowski
ID: 13545915
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
 

Author Comment

by:DKimzey
ID: 13546122
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
 
LVL 1

Expert Comment

by:jlazanowski
ID: 13546201
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
 
LVL 101

Accepted Solution

by:
mlmcc earned 75 total points
ID: 13546294
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
 

Author Comment

by:DKimzey
ID: 13546301
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
 
LVL 1

Expert Comment

by:jlazanowski
ID: 13546411
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
 

Author Comment

by:DKimzey
ID: 13546445
A new page
0
 
LVL 1

Assisted Solution

by:jlazanowski
jlazanowski earned 300 total points
ID: 13546503
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
 

Author Comment

by:DKimzey
ID: 13547043
Thank you for your help!
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 13550819
Glad i could help

mlmcc
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question