The Stealth Subreport

Wednesday 25 October 2006 @ 2:35 pm

Often subreports are used in Crystal Reports to retrieve an unrelated value from a different table or data source. In many of these cases you do not want to see the subreport at all. You just want to retrieve your value and use it. You soon realize, however, that if you suppress the subreport object, or if you suppress the section that contains the subreport, the subreport will simply not run.

To make a subreport run but be completely invisible you suppress all of the sections in the subreport. This makes the subreport completely invisible, but still allows it to run. You could stop here, but the section that contains the subreport will still take up some space on your report, even though it is empty space. Some people just make this section (and the subreport object) very small so that it is hardly noticeable. But go one step further for an even better solution. If you are using version 9 or later, go into the Section Expert for the section that contains the subreport, and chek “Suppress Blank Section”. This will make the section invisible but the subreport will run.

If you are using v8.5 you can set the section in the main report (the section containing the subreport) to “Underlay following sections”. This causes Crystal to superimpose the blank subreport section over whatever will print below the subreport. Now it is both invisible and it doesn’t take up any space. But with this method the section below the subreport must appear at least as frequently as the section containing the subreport. Otherwise the subreport section won’t have anything to hide behind. So I could hide a subreport in Group Header A above a visible Group Header B or even above visible details below the Group Header. However I can’t hide a subreport in the Details section above a Group Footer, because the Group Footer doesn’t print as often as the details.

If you like techniques like this you should check out the Crystal Reports “Expert Techniques” guides in my library.








2 Responses to 'The Stealth Subreport'

  1. JESii7 - November 19th, 2006 at 2:14 pm

    I prefer to use the “Suppress if blank…” options, rather than underlay — it seems more straightforward to me.

    Simply check “Suppress Blank Subreport” in the Format Subreport/Subreport tab and check “Suppress Blank Section” in the Section Expert. The section & subreport never appears and you don’t have to worry about future maintenance gotcha’s. FYI… I tend to put one subreport in a section for granularity of control.

  2. Ken Hamady - November 19th, 2006 at 4:44 pm

    Thanks, that method would work just as well if you are in versions 9 or later. The Underlay method works in older versions as well as the newer versions.


Leave a Reply

Jeff-Net
Recrystallize Pro

Crystal Reports Server