简体   繁体   English

水晶报表:无法识别记录选择中的Null值

[英]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.

相关问题 Crystal Reports参数发送NULL而不是选择的值 - Crystal Reports parameter sending NULL instead of chosen value Crystal Reports-通过文本范围选择记录 - Crystal Reports - Select records via range of text 用于在水晶报表中选择成员的SQL表达式 - SQL expression to select members in crystal reports Crystal Reports 试图从 2 个表中获取 select - Crystal Reports trying to select from 2 tables SQL转换(varchar, <fieldname> )等价于Crystal Reports记录选择公式 - SQL Convert(varchar, <fieldname>) equivalent in Crystal Reports record selection formula 在记录集中的非NULL值之后选择具有第一个NULL值的每个记录 - Select each record with first NULL Value after non-NULL value in record set 与复制的Crystal Reports相比,SSRS / SSMS记录检索非常慢 - SSRS / SSMS record retrieval very slow compared to replicated Crystal Reports 如果id只有一条记录,则选择一条有空值的记录,当id有多条记录时,选择非空值 - Select a record having null if the id has only one record and select not null value when the id has more than one record Crystal Reports中带有嵌套Select语句的错误SQL语法不正确 - Incorrect SQL Syntax with nested Select statements in Crystal Reports 获取动态查询选择字段以显示在 Crystal Reports 中 - Getting dynamic query select fields to show in Crystal Reports
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM