I have the custom forumla in my record seletion formula editor in Crystal reports 8.5
{_v_hardware.groupName} = {?companyname} and ({_v_hardware.D开发者_如何学CriveLetter} = "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.
精彩评论