Beware of Null

Crystal deals with null values very poorly which can cause a great deal of difficulty for beginners.

Lets consider the following example: You want to create a report which will display a person's full name. The database contains a table called Person with field names of Given, Other and Family so to concatenate these one may try:

{Person.Given} & " " & {Person.Other} & " " & {Person.Family}

However, this will fail whenever Person.Other (Middle Name) is Null and the returned value will be Null regardless of the values of Given and Family.

You must test for Null using code such as the following:

If (isNull({Person.Other})) Then
{Person.Given} & " " & {Person.Last}
Else
{Person.Given} & " " & {Person.Other} & " " & {Person.Last}


Simply utilize the If Then statement with the isNull function to test for Null and the problem will be solved!

The bottom line is that whenever there is the possibility of a Null value you should test for it even if logically it would not appear to make a difference. Crystal Reports does perform erratically when it encounters null values!

 

@Copyright 2002-2004 Keptin Consulting Services. All Rights Reserved