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


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;
  1. Put the "RecordCount" field into the reports detail section. Supress the field by checking "Supress" on the format editor.
  2. Create a page header section by right clicking the page header section and choose "insert section below" from the context menu.
  3. 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.
  4. Click the conditional formula editor button to the right of the suppress checkbox. Set the formula to be:
Not(Isnull({@RecordCount}))
  1. Add a text object to the report that contains the message you want to display to the user when no data is returned.

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.