Search code examples
crystal-reportserror-suppressionsuppression

I need the details section to suppress if a custom date field is blank in Crystal Reports


I have the following suppression formula in the details section:

{JCJM.udRough} <= #1/1/2013 12:00# AND {JCJM.udTrim} <= #1/1/2013 12:00#

and it works. However, I also need it to suppress if the udRough or udTrim field is blank. When I try to add

OR {JCJM.udRough}=""

it says that a date-time is expected where the blank quotes are. Can someone please help?


Solution

  • As a general rule in CR, if a field can be null then you should explicitly check for that case first in a formula, otherwise it will not evaluate properly. Otherwise, CR will treat it like an unhandled exception.

    So in your case, CR is short-circuit evaluating the expression {JCJM.udRough}<=#1/1/2013 12:00# as the very first thing, sees that the field is null, and stops evaluating the rest of the formula since it has encountered an exception.

    What you need is:

    (isnull({JCJM.udRough}) or {JCJM.udRough} <= #1/1/2013 12:00#) and (isnull({JCJM.udTrim}) or {JCJM.udTrim} <= #1/1/2013 12:00#)