views:

753

answers:

1

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}
   )
A: 

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.

Heather
yea, thats a typo on my part. thanks for pointing that out
phill
I just tried the if then and it gives me the same result.. weird
phill
Strange. Try my edit to see if that gives you different results.
Heather
cool...just tried it.. same result.. thanks
phill
Darn, I'm stumped. I hope you can find a solution to this phill.
Heather
me too.. thanks for your help
phill
figured it out.. put the 'if {_v_hardware.DriveLetter} = "C" then {_v_hardware.groupName} = {?companyname}' in Parenthesis and it worked.. thanks!
phill
Awesome! Glad I could help!
Heather