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

Reseting shared variables

Status
Not open for further replies.

neeko1226

MIS
Jul 24, 2003
82
US
I'm using Crystal XI.

Backround Info - I have a main report with several subreports inserted into it. Each of the subreports is grouped by state (as the outermost group), and state is how my main report links to each of the subreports. Because I need each subreport to display different page footers, my main report has a page footer section for each sub-report that is displayed with that sub-report only. I'm passing a shared variable from my subreports to the corresponding page footer section on the main report and it is diplayed in a footnote formula.

The problem occurs when the data in the subreport is more than one page long. This causes the shared variable displayed in the page footnote to show the value of the previous state on the first page of data and the correct value on the second page.

Does anyone know how I can get the shared variable to show the correct value on both pages if the data is more than one page long?

 
You can't. The variable cannot pass until the subreport has finished executing, so it won't be available until page 2. If you need the page footer on both pages, you might be better off creating a fake page footer within the subreport. Place the "special field" recordnumber on the subreport detail section and then note how many records appear on the first page. Let's say the result is 45. Then insert a detail_b section and place your page footer fields there. Then go to the section expert (still within the subreport)->detail_b->suppress->x+2 and enter:

remainder(recordnumber,45) <> 0

Then also for detail_b, go to new page after->x+2 and enter:

not onlastrecord and
remainder(recordnumber,45) = 0

This will make the last detail_b on the page act as a page footer.

-LB

 
Unfortuneately, I don't know how many records there will be on each page. This report is bound by several formatting requirements that I must comply with so I cannot limit the number of records on page. That's why I have the page footers on the main report in page footer subsections.

Can I place the shared variable somewhere else on the main report so it isn't picked up until after the sub-report executes?
 
I guess another way you could do this is to place a copy of the subreport in a group header_a section above the one in which the subreport is located (let's assume it is in gh_b). Then suppress all sections within the subreport, format the subreport to "suppress blank subreport", and format the gh_a section to "suppress blank section" or to "underlay following section". Since all is suppressed the shared variable in the initial copy should be able to pass the shared variable to the main report page footer. It's just that you are doubling the hit on performance by adding these extra subreports.

-LB
 
I don't follow. Let me give you the layout of my main report:

RH: Suppressed
PH: Suppressed
GH1(State): Suppressed
Details: Suppressed
GF1a: Subrpt1
GF1b: Subrpt2
GF1c: Subrpt3
RF: Suppressed
PFa: Footnote formulas for Subrpt1, ShrdVar1
PFb: Footnote formulas for Subrpt2, ShrdVar2
PFc: Footnote formulas for Subrpt3, ShrdVar3
 
As LB states, the page footers will appear PRIOR to the subreport completing if the subreport is more than one page.

You should consider placing the values in the report footer, then you'll have all of the values together upon completion, or you can show the totals at the end of each subreport.

The alternative is as LB suggested, execute all of the subreports in the group header first, and get the values, then run the subreports in the group footer as you do now, and you'll already have the values in shared variables.

As you can see, the solution is kludgy.

I suggest that you post your database/connectivity, and what's in the subreports, you can probably eliminate them by using SQL, which should be the goal anyway for performance reasons.

-k
 
For the alternative, would I create a group header section for each subrpt, or do I simply place them all in the same group header?

I would like to explore the SQL option, but I'm under a time restraint.
 
You can place the subreports in one section
 
It doesn't matter where you palce the subreports, nor the order in the group header, just make sure that you have the shared variables being set there, and not in the group footer versions.

You can copy and paste the subreports to speed this up.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top