Crystal Reports - How to display a message that a report contains no data

Posted: 05/22/2007

Scenario:

You have a report and you want to display a message that tells the user there were no records returned instead of having Crystal show a blank page or an empty template.

Solution:

  1. Create a formula named "RecordCount" as the following:
        WhileReadingRecords;
        Global Numbervar RecordCount;
        RecordCount:=RecordCount+1;
            
  2. Put the "RecordCount" field into the reports detail section. Supress the field by checking "Supress" on the format editor.
  3. Create a page header section by right clicking the page header section and choose "insert section below" from the context menu.
  4. Right click the page header you just created and choose "Section Export" from the context menu. In the section expert check the "Underlay Following Sections" checkbox.
  5. Click the conditional formula editor button to the right of the suppress checkbox. Set the formula to be:
        Not(Isnull({@RecordCount}))
            
  6. Add a text object to the report that contains the message you want to display to the user when no data is returned.