Link to home
Start Free TrialLog in
Avatar of John Gillen
John GillenFlag for United States of America

asked on

Blank Crystal report when no records are found

I'm using Crystal 11 and the crystal server.  I'm generating an exception report and emailing the report to the users.  The issue is there a way to suppress the actually creation of the report if no records are found? I've checked the suppress printing if no records found in the report options, but the server still sends a empty report to the user.

Thanks
Avatar of Kurt Reinhardt
Kurt Reinhardt
Flag of United States of America image

When  users receives a blank report, they automatically assume the report is 'broken'.  Likewise, if a report isn't run at all,users assume that the report is 'broken'. To mitigate this risk, I traditionally create a conditionally suppressed text box with a message like 'No records returned...'.  If the report is parameterized or filtered in some way, I'd recommend that you incorporate the parameters or filters into the message like 'No records returned from {?From Date} through {?Through Date} where patient # = {?patnum}'.  This personalizes the report and makes the message as meaningful as possible.  This is especially useful for reports that are run on-demand by the users since the report message will clearly show them the parameter values they entered at run-time.

~Kurt
Avatar of John Gillen

ASKER

This report is transaction and time based.  It is scheduled to run every 15 minutes and in theory the users would be happy to not receive any emails for a given day.  They do not want to get an email stating that all is well, only when there are problems.  I was able to get something like this working using alerts, but then the user wanted to format the alert to make it more readable.  It appears that all I can do with alert messages is create a single line string, so that did not help.
The users do not want to have to click on a link to the report and then have to login to the server to see the report.
OK - one option is to create a formula that will cause the report to fail if there's no data.  A common formula would be one that divides one value by another, forcing a division by zero error when there are no records.  Ex:

Count({table.field1})/Count({table.field2})

If there are no records, then the report should fail with a division by zero error.  Make sure you don't have the report scheduled to rerun if it fails.  Also, make sure you don't have failure notification turned on for this particular report.  If the report fails, it won't be emailed.

~Kurt
Yes this will work.  I can understand Crystal not wanting their program to come to a sucessful conclusion with no output, that would make the end users crazy.  

Thanks
I have tried the division by zero approach using the Count function.  What appears to be happening is when there are no records present the Count funtion returns a null value not zero as the report does not fail with a divide by zero error.
You're right - I remember doing this for Seagate Info, but the more recent versions of CR are 'too intelligent' to allow you to deliberately force an error.  The only alternative I can see is to base the report on a stored procedure.  The stored procedure would be written to return a valid recordset when there is data, but return an invalid recordset when there isn't any data.  The invalid recordset will cause the report to fail when it is scheduled.

~Kurt
I was able to get around this with global variables and some formulas.  I set a variable to 0 if the IsNull(Count{field1})) was true and this setup a divide by zero error in the report footer section and a subsequent report failure and no email.  Not very eloquent, but funtional in this case.  The stored procedure approach would work as well.

ASKER CERTIFIED SOLUTION
Avatar of Kurt Reinhardt
Kurt Reinhardt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial