CRYSTAL REPORTS XI
  1. Within the subreport, go to Report > Section Expert
  2. Mark the Suppress Blank Section checkbox for each section that is not already suppressed.
  3. In the main report, right-click on the subreport box and select Format Subreport.
  4. On the Subreport tab, mark the Suppress Blank Subreport checkbox
  5. Click OK

CRYSTAL REPORTS 8.5

The main steps are:
  • Creating a duplicate subreport
  • Inserting the duplicate subreport in the main report
  • Creating a formula to test if the subreport is blank
  • Conditionally suppressing a section that contains original subreport
  • Minimizing a duplicate subreport and resizing the section
Create a Duplicate Subreport
  1. From the main report, right-click on the subreport and select Save Subreport As
  2. Provide a name for the duplicate subreport and click Save
Insert Duplicate Subreport into the Main Report
  1. In the main report, go to Report > Section Expert
  2. Select the section that contains the subreport and click the Insert button at the top. For example, if the original subreport is contained in the Group Header #1 section, select this section and click the Insert button. This will create Group Header #1 a and Group Header #1 b.
  3. Click OK
  4. Drag the subreport into the new section (for example, Group Header #1 b)
  5. Go to Insert > Subreport
  6. Select the first option to choose an existing report
  7. Browse for the duplicate subreport .rpt file and open it
  8. Click OK and place the subreport into the blank section (for example, Group Header #1 a)
  9. Go to Edit > Subreport Links. The top drop down box will contain both the original and duplicate subreports. Compare these two subreports and ensure that the fields in the Filed(s) To Link To box are the same. Also, check that the parameter in the bottom-left drop down box and the field in the bottom-right drop down box are the same.
  10. Click OK
Create a Formula to test if the Subreport is blank
  1. Right-click on the duplicate subreport and select Edit Subreport
  2. Go to View > Field Explorer to open the Field Explorer window
  3. Right-click on Formula Fields and select the New
  4. Enter a name for the formula and click OK
  5. Create a formula similar to the following:
    //@CheckForNull
    WhilePrintingRecords;
    Shared BooleanVar Suppress;
    If IsNull(Count({Field_Name})) or Count({Field_Name}) = 0
       then Suppress:= TRUE
    Else Suppress:= FALSE
  6. Click Save and Close on the formula
  7. Drag the formula into the Report Header or Footer section of the report
Conditionally suppress the section containing the Original Subreport
  1. In the main report, go to Report > Section Expert
  2. Select the section that contains the original subreport (for example, Group Header #1 b)
  3. Click the X+2 button next to Suppress (No Drill-Down). The checkbox does not need to be marked.
  4. In the Format Formula Editor, create a formula similar to the following:
    //The section will be suppressed if
    //variable Suppress is True
    WhilePrintingRecords;
    Shared BooleanVar Suppress = True
  5. Click Save and Close
  6. Click OK
Now when you preview the report, you notice that the sections that contain a blank subreport are suppressed. However, the section that contains the duplicate subreport is visible on the main report. In order to suppress the section still visible you must minimize and resize the section.

Minimize the Duplicate Subreport & Resize the Section
  1. In the duplicate subreport, suppress all of the sections
  2. In the main report, right-click the duplicate subreport and select Format Subreport
  3. Go to the Border tab
  4. From the Line Style drop down lists, select None for Left, Right, Top, Bottom
  5. Click OK
  6. In the main report, resize the section that contains the duplicate subreport to be as small as possible