Kevin
Kevin

Reputation: 465

In crystal reports how to I make a default value appear on a null?

I'm using VS 2010 but I'm not sure on the Crystal reports what year it is. 2008 or 2010? I want to display 'N/A' when a date field is null. here is my formula

  If isnull({usp_print_get;1.Cit_Date}) then 'its null' else 'not null'

It will print 'not null' when there is a date but if there isn't a date it just leaves the space blank instead of printing 'its null' I've checked the database and the date field for that record is indeed null and not a space or empty string. Any help is appreciated. Eventually I'd like to print either 'N/A' when its null or the actual Cit_Date. Right now I'm just using the strings to test.

Upvotes: 0

Views: 21830

Answers (1)

ca_wan
ca_wan

Reputation: 321

Looking at your formula, it should work, it's just the syntax that is odd. Use double quotes instead of single.

IF isnull({usp_print_get;1.Cit_Date}) THEN 
  "N/A"
ELSE
  " "

But if you want to want to use the date with this formula you will have to convert it to a string. The output has to be the same data type, it messes up the Formatting option.

IF isnull({usp_print_get;1.Cit_Date}) THEN 
  "N/A"
ELSE
  TO_TEXT({usp_print_get;1.Cit_Date}, "MM-dd-yyyy")

Format the date however way you want.

If you are debugging, put it formula and the date column side by side in your report.
It's easier to check if it's working.

Upvotes: 3

Related Questions