Crystal Reports: Display a Message When Report Has No Data

Often it is desirable to display a message, such as ‘No matching records’, when a report does not contain data. Unfortunately, Crystal Reports does not have a function to easily identify this state.

Fortunately, this functionality can be approximated by building a formula that manually counts the records. This formula, excuted during the report’s ‘WhileReadingRecords’ phase, will increment a Global variable. To work correctly, this formula will need to reside in the report’s Details section.

To build a report that uses this functionality, follow these steps:

  1. Create a formula named ‘Records’.
  2. Set the formula’s text to be:
    //Excute this formula as records are read into the report
    //define a variable that is available throughout the 'main' report
    Global Numbervar Records;
    //increment the variable
  3. Place this field in the report’s Details section. Suppress the field by checking ‘Suppress’ check box on the Format Editor’s Common tab.
  4. Create a new Page Header section by right-clicking the Page Header section and choose ‘Insert Section Below’ from the context menu.
  5. Right-click the newly-created Page Header and choose ‘Section Expert…’ from the context menu. Check the ‘Underlay Following Sections’ checkbox.
  6. Click the Conditional-Formula Editory button to the right of the ‘Suppress’ checkbox. Set the formula’s text to:
    //If the field isn't null, suppress the section; the field will only be null when
    //the report does not contain data.
  7. Add a Text Object to the report containing the desired message. Place the Text Object in the newly-created Page Header section.
  8. Test the report.

Report with Data

Report without Data

Sample Report

5 thoughts on “Crystal Reports: Display a Message When Report Has No Data

  1. ErTR

    Great article. But I can’t figure it out yet how can i make invisible the first header(section with columns in it) when there is no data? Thanks for pure info.

  2. ErTR

    Oh i’ve find out now: i checked the “hide” checkbox of first header on section expert. Then i write this for formula:


    I’m pretty new on CR your article helped me a lot in general understanding of how CR works. Thanks again have a nice day. (captcha sucks on chrome 😉 )

  3. Ian Taylor

    Works like a charm, thanks! I was trying to use a Count() function in the report footer but it was not working for some reason. But this works great.

  4. John Gardner

    This is awesome! You solved a problem that had me pulling out my remaining hair. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *