IsNull Function

Named Arguments

No

Syntax

IsNull(expression)


expression

Use: Required

Data Type: Variant

An expression containing string or numeric data.

Return Value

Boolean (True or False).

Description

Determines whether expression contains any Null data.

Rules at a Glance

  • If the expression passed to IsNull contains null data, True is returned; otherwise, IsNull returns False.

  • All variables in expression are checked for null data. If null data is found in any one part of the expression, True is returned for the entire expression.

  • Although any data type can be passed to the function, only a variant variable can be null. As a result, it makes little sense to pass nonvariant data to the function, since it must always return False.

Programming Tips and Gotchas

  • IsNull is useful when returning data from a database. You should check field values in columns that allow Nulls against IsNull before assigning the value to a collection or other variable. This stops the common "Invalid Use of Null" error from occurring.

  • IsNull is the only way to evaluate an expression containing a null. For example, the seemingly correct statement:

    If varMyVar = Null Then

    always evaluates to False, even if varMyVar is null. This occurs because the value of an expression containing Null is always Null and therefore False.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.130.231