简体   繁体   中英

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

{_v_hardware.groupName} = {?companyname} and ({_v_hardware.DriveLetter} = "C" or 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. Am I handling the null values incorrectly? I have also tried setting the {_v_hardware.DriveLetter} = NULL and that does not work either.

I should add the report is talking to SQL Server. the records are reading NULL in the table.

Update: If I use the query

{_v_hardware.groupName} = {?companyname} and isNull({_v_hardware.Driveletter})

it will list the records with just the Null values in the DriveLetter field and the companyname

If I use the query

{_v_hardware.groupName} = {?companyname} and {_v_hardware.DriveLetter} = "C"

this also lists all records with the driveletter "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. Sometimes I've had to break field checks into blocks when a NULL value is possible:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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