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. Set the section in the main report (the section containing the subreport) to “Underlay following sections”. This causes it to superimpose the blank subreport over whatever prints below the subreport. Now it is both invisible and it doesn’t take up any space.

The only limitation is that 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 Group Header B or even above the details that are 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. The only time you can hide a subreport in the Details section is when it is above another details section that will remain visible.

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