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

Global variable problem 1

Status
Not open for further replies.

MJSQA

Technical User
Nov 15, 2001
30
0
0
US
I have a report that has a subreport in each detail section. The subreport can grow and so I never know how long it is going to be. It may span to a second page. If it does then I need to reprint some of the detail section on the second page.
I am handling this by adding a detail section b. If the subreport spans to the second page then I print the detail section b which has the fields that I need.
I have a forumula at the beginning of section a that says this:

WhilePrintingRecords;
shared booleanVar RePrintCoName;

RePrintCoName := False

and then I have a forumula in the page footer that does this:

WhilePrintingRecords;
shared booleanVar RePrintCoName;

RePrintCoName := True

I then do a suppress on detail section b if RePrintCoName is false. My problem is that it always suppresses detail section b no matter what. I had tried this with global rather than shared and then it never suppressed section b no matter what.

Can anybody give me a hand here?
 
hmmm...If I read you correctly the subreport when printed in the main report spans 2 pages in the main report and because of this you want some kind of action to be taken in the subreport

I don't know if you have an control here. As far as the subreport is concerned it doesn't know it is being split across 2 pages (I am pretty sure of that) It may well be on a single page within itself. I don't think you could do anything with your current design...perhaps a rethink of the report design is needed.

For example...do you really need so many subreports?
Jim

JimBroadbent@Hotmail.com
 
I am not trying to have something happen on the subreport. If the subreport causes the detail section to span to another page I want the detail section b to print. If it does not span a page then I want detail section b to be suppressed. Detail section b is in the main report.
 
well then perhaps you can use the pagenumber for this in the main report.

in the section before you launch the subreport place this formula and suppress it.

@PageFlag
whilePrintingRecords;
numbervar currentPage := pagenumber;

then

in Detail section b in the conditional suppress in the Section Expert

WhilePrintingRecords;
numbervar currentPage;

If currentPage = pagenumber then
true
else
false;


that may do it...the @PageFlag must set prior to running the subreport though...if necessary create a new suppressed section and place the @PageFlag formula there
Jim

JimBroadbent@Hotmail.com
 
I tried that. Still not working. For some reason it appears that Crystal evaluates all of the detail sections before it prints any of them. So what happens is that it evaluates the suppression of detail a and b when it starts to print a. Therefore it chooses to suppress b because it evaluates b at the same time as a and so at that evaluation time they are on the same page.

Thanks for your help. I really appreciate it.
 
No Problem....what you said is probably true and is the reason I use "WhilePrintingRecords" in all formulas that are not required for grouping or summary operation. Jim

JimBroadbent@Hotmail.com
 
I am using "WhilePrintingRecords".

I have a formula that I have placed in section b so that I can make sure that it has the correct data from the variable. For some reason the variable gets reset to current page on every page. (I checked and there are no other places where this is being reset.) I finally created a blank group section and put the formula in that. It is not how I wanted to do it, but it has taken care of the problem.

Thanks again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top