Home | SkillForge Blog | How to Indicate Blank Results in Crystal Reports

How to Indicate Blank Results in Crystal Reports

Crystal Reports, SAP Crystal Reports

When we print a report in any database-connected situation, we sometimes get blank results, i.e. nothing to report. But we certainly don’t want to waste paper on such a thing. So how can we let a user know about it without sending more than one page (at most) to a printer? If you routinely run reports that can come up blank, this might be important.

Some programs can show an alert message to this effect: “No results match your criteria.” And though Crystal Reports has what it calls Report Alerts available, I haven’t yet found a direct way to pop up an alert for blank results. But I did manage to dig up at least one way to reduce the waste.

blank results message

We can start with any report, and add a second report header (for example) to it. We insert a message such as “No records found to match criteria” in a text box there; making it big red letters or something is helpful.

The key is to use the Section Expert, and suppress this section UNLESS the report shows blank results.

section expert  formula

We go to the Expert, click the X2 button next to Suppress (No Drill-Down), and enter a formula like this:

IF COUNT({Orders.OrderID}) < 1 THEN false ELSE true

where the field can be anything in the Details section of the report. If no records show, the Details section will have nothing, and the condition will kick into operation. The user will then know there’s nothing.

If we want to be a bit more thorough, we can also conditionally suppress the other sections the other way round:

IF COUNT({Orders.OrderID}) < 1 THEN true ELSE false

so when the “blank results” message shows up, nothing else will. Except maybe the date and time in an unsuppressed section, or whatever else would be helpful.

blank results

I plan to keep looking for a way to have a Report Alert do this, as it would be a rather more “correct” solution. But the main point is to alert the user of blank results, and the technique I describe here works.

For more, take a look at our Crystal Reports courses.