#### Dealing with null values

For some products, such as the Guardian Chain Lock, a color value was not recorded and so the {Product.Color} field has a null value in the database for that record. In general, when Seagate Crystal Reports encounters a null valued field in a formula, it immediately stops evaluating the formula and produces no value. Thus, the Guardian Chain Lock record does not have any word printed beside it. If you want to handle null field values in your formula, you must explicitly do so using one of the special functions designed for handling them: IsNull, PreviousIsNull or NextIsNull. Here is an example of how to fix the above example using IsNull:

    If IsNull({Product.Color}) Or _
       InStr({Product.Color}, " ") = 0 Then
       formula = "basic"
    Else
       formula = "fancy"
    End If

Relating to operators, when Seagate Crystal Reports evaluates the condition:

    IsNull({Product.Color}) Or _
    InStr({Product.Color}, " ") = 0

It first evaluates IsNull ({Product.Color)), and when it determines that this is True, it knows that the whole condition is True, and does not need to check whether

`InStr({Product.Color}, " ") = 0.`

In other words, Seagate Crystal Reports will stop evaluating a Boolean expression when it can predict the results of the whole expression. In the following example, the formula guards against attempting to divide by zero in the case that denom is 0:

    Dim num As Number, denom As Number
    ...
    If denom <> 0 And num / denom > 5 Then
    ...

Note: Visual Basic does not support this technique, since all parts of a Boolean expression in Visual Basic are evaluated, even if not necessary.

Seagate Software, Inc. http://www.seagatesoftware.com Please send comments to: techpubs@seagatesoftware.com