Returns a Boolean value that indicates whether an expression contains no valid data (Null).
Syntax
IsNull ( expression )
The required expressionargument is a Variant containing a numeric expression or string expression.
Remarks
IsNull returns True if expression is Null; otherwise, IsNull returns False. If expression consists of more than one variable, Null in any constituent variable causes True to be returned for the entire expression.
The Null value indicates that the Variant contains no valid data. Null is not the same as Empty, which indicates that a variable has not yet been initialized. It is also not the same as a zero-length string (""), which is sometimes referred to as a null string.
Important: Use the IsNull function to determine whether an expression contains a Null value. Expressions that you might expect to evaluate to True under some circumstances, such as If Var = Null and If Var <> Null, are always False. This is because any expression containing a Null is itself Null and, therefore, False.
Query examples
Expression |
Results |
SELECT ProductID, isNull(Discount) AS Expr1 FROM ProductSales; |
Returns values from the field "ProductID", evaluates if the values in the field "Discount" are Null, returns -1 (True) and 0 (False) in column Expr1. |
SELECT ProductID, isNull(Discount) AS NullStatus FROM ProductSales; |
Returns values from the field "ProductID", evaluates if the values in the field "Discount" are Null, returns -1 (True) and 0 (False) in column NullStatus. |
VBA example
Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.
This example uses the IsNull function to determine if a variable contains a Null.
Dim MyVar, MyCheck
MyCheck = IsNull(MyVar) ' Returns False. MyVar = "" MyCheck = IsNull(MyVar) ' Returns False. MyVar = Null MyCheck = IsNull(MyVar) ' Returns True.