简体   繁体   English

在Crystal报表中,如何使默认值出现在null上?

[英]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. 我正在使用VS 2010,但是我不确定在Crystal报表上是哪一年。 2008 or 2010? 2008年还是2010年? I want to display 'N/A' when a date field is null. 当日期字段为空时,我想显示“ N / A”。 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. 有日期时它将打印“ not null”,但如果没有日期,则将空格留空而不是打印“ null”。我已经检查了数据库,该记录的日期字段确实为null,并且不是空格或空字符串。 Any help is appreciated. 任何帮助表示赞赏。 Eventually I'd like to print either 'N/A' when its null or the actual Cit_Date. 最终,我想将'N / A'打印为null或实际的Cit_Date。 Right now I'm just using the strings to test. 现在,我只是在使用字符串进行测试。

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. 输出必须是相同的数据类型,它弄乱了Formatting选项。

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. 检查它是否在工作更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM