[英]crystal reports : not recognizing Null value in record select
I have the custom forumla in my record seletion formula editor in Crystal reports 8.5 我在Crystal Reports 8.5的记录选择公式编辑器中有自定义forumla
{_v_hardware.groupName} = {?companyname} and ({_v_hardware.DriveLetter} = "C" or isNull({_v_hardware.Driveletter}) {_v_hardware.groupName} = {?companyname}和({_v_hardware.DriveLetter} =“ C”或isNull({_ v_hardware.Driveletter})
I'm trying to list all records with a drive letter C or has a Null value and it currently lists all records with the drive letter C but not the ones with null. 我正在尝试列出具有驱动器号C或具有Null值的所有记录,并且当前列出具有驱动器号C的所有记录,但没有列出具有null的记录。 Am I handling the null values incorrectly? 我是否错误地处理了空值? I have also tried setting the {_v_hardware.DriveLetter} = NULL and that does not work either. 我也尝试过设置{_v_hardware.DriveLetter} = NULL,但这也不起作用。
I should add the report is talking to SQL Server. 我应该添加报告正在与SQL Server通信。 the records are reading NULL in the table. 记录在表中读取为NULL。
Update: If I use the query 更新:如果我使用查询
{_v_hardware.groupName} = {?companyname} and isNull({_v_hardware.Driveletter}) {_v_hardware.groupName} = {?companyname}和isNull({_ v_hardware.Driveletter})
it will list the records with just the Null values in the DriveLetter field and the companyname 它将在DriveLetter字段和公司名称中仅列出Null值的记录
If I use the query 如果我使用查询
{_v_hardware.groupName} = {?companyname} and {_v_hardware.DriveLetter} = "C" {_v_hardware.groupName} = {?companyname}和{_v_hardware.DriveLetter} =“ C”
this also lists all records with the driveletter "c" 这还将列出驱动器号为“ c”的所有记录
thanks in advance 提前致谢
Solution by heather: 希瑟的解决方案:
if IsNull({_v_hardware.Driveletter) then
{_v_hardware.groupName} = {?companyname}
else
(if {_v_hardware.DriveLetter} = "C" then
{_v_hardware.groupName} = {?companyname}
)
I've seen Crystal do funny things depending on the order you evaluate your fields. 我见过Crystal根据您评估字段的顺序来做有趣的事情。 Sometimes I've had to break field checks into blocks when a NULL
value is possible: 有时,当可能使用NULL
值时,我不得不将字段检查分成多个块:
if IsNull({_v_hardware.Driveletter) then {_v_hardware.groupName} = {?companyname} else if {_v_hardware.DriveLetter} = "C" then {_v_hardware.groupName} = {?companyname} else false;
Its ugly, but it may work if that is the case. 它很丑陋,但如果是这样,它可能会起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.