Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

9.22 Tutorial 9-9 Hiding Empty Subreports

Hiding Empty Subreports

Another problem that you’ll eventually encounter with subreports is when they don’t have any data but they still print. You’ll see the column headers but no detail records. In fact, you can see this in the previous tutorial. The column headers for the credit report are there, but no data is displayed. This makes for an unprofessional looking report. Correcting this requires making two changes.

The first change is suppressing the subreport when it is blank. You do this by going to the Format Editor dialog box and setting the property Suppress Blank Subreport. But just suppressing the subreport will still leave a large empty section on the report. The second change is modifying the section on the main report that holds the subreport so that it is also suppressed when the subreport is empty. Do this by going into the Section Expert and setting the property Suppress Blank Section. Since we are suppressing the entire section of the main report when the subreport has no data, this is another reason why you should put subreports in their own section.

Tutorial 9-9. Hiding Empty Subreports

  1. Open the report ‘Customer Net Sales Corrected.rpt’.
  2. We want to suppress the subreport when it doesn’t have any data, so right-click on it and select Format Subreport. This opens the Format Editor dialog box.
  3. Click on the Subreport tab and select the property Suppress Blank Subreport. If the subreport doesn’t have any data, then all the report objects will be suppressed.
  4. Click the OK button to save your changes.
  5. Now we want to modify the main report so that the section holding the subreport is suppressed as well. Unfortunately, section #1a also has the subtotal for the total sales in it. We need to put the subreport in a new section all by itself.
  6. On the left side of the designer, right-click Group Footer #1a and select Insert Section Below. This creates a new section #1b and renames the previous section #1b as #1c.
  7. Drag the subreport down into Group Footer #1b. Now the subreport is in its own section with no crossover from fields in the main report.
  8. Right-click the Group Footer #1b name and select Section Expert. This opens the Section Expert dialog box.
  9. Click the option Suppress Blank Section property for Group Footer #1b. Click the OK button to save your changes. This will suppress the section when the subreport is empty.
  10. Preview the report and skip to page 8. You’ll see that the Customer Credits subreport is completely gone because this customer has no credit records. This is a nice improvement.


10. Save the report as Customer Net Sales Empty Subreport.rpt.