 |
Contributed by John White, BOCP & BOEP. When John isn't creating world-class Crystal Reports or teaching, he can be found at the local ice rink, either scoring goals for his hockey team or refereeing high school games. |
Passing Shared Variables from a Suppressed Subreport
Subreports are most often used for displaying unrelated data in a single report. For instance, an executive might want to see both accounts payable and accounts receivable data in the same report. There is no logical connection between the two data sets, so the main report would contain the A/P data and the subreport would contain the A/R data. To the user it would appear to be one report.
However, sometimes you need to be able to use a value from the subreport in the main report, and to do so you would use a shared variable. In this case you don’t want the subreport to be visible at all; it only exists to retrieve the desired value and pass it to the main report.

The problem is that if you suppress the section in the subreport containing the variable, it will not return a value. The workaround is usually to suppress the formula field, then make the field, the section containing it, and the subreport itself as small as possible to take up the minimum amount of space in the main report.

If the subreport is placed in a group header, it will repeat for every group value. That means that if you make the subreport only 1/8th of an inch tall, the report will be an additional inch longer for every eight group values - that extra space can really add up. In addition, there are often awkward blocks of white space that detract from the appearance of the report.
Here’s an easy way around this problem:
1. Suppress each section of the subreport.

2. In the main report, place the subreport in its own section, then select the “Suppress Blank Section” option in the Section Expert.

3. In the main report, right click on the subreport and select Format Subreport. On the Subreport tab, select Suppress Blank Subreport.

Now the entire section is suppressed, but the variable is still properly passed to the main report and there is no additional white space cluttering up your report.

Tell us what you thought about this article at cnenews@cne.com |