Returns a Boolean value that indicates whether an expression contains no valid data (Null).
IsNull(expression)
The expression argument can be any numeric or string expression.
IsNull returns True if expression is Null, that is, it contains no valid data; 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.
IsArray Function, IsDate Function, IsEmpty Function, IsError Function, IsMissing Function, IsNumeric Function, IsObject Function, TypeName Function, Variant Data Type, VarType Function.
This example uses the IsNull function to determine if a variable contains a Null.
MyCheck = IsNull(MyVar) ' Returns False.= ""= IsNull(MyVar) ' Returns False.= Null= IsNull(MyVar) ' Returns True.
The following example uses the IsNull function to determine whether the value of a control object is Null. If it is, a message prompts the user to enter data. If the value is not Null, a message displays the value of the control object.
Sub ControlValue(ctlText As Control) Dim strMsg As String, strCRLF As String strCRLF = Chr(13) & Chr(10) ' Check that control is text box. If ctlText.ControlType = acTextBox Then ' If value of control is Null, prompt for data. If IsNull(ctlText.Value) Then strMsg = "No data in the field '" & ctlText.Name & "'." _ & strCRLF & "Please enter data for this field now." If MsgBox(strMsg, vbQuestion) = vbOK Then Exit Function End If ' If value is not Null, display value. Else MsgBox (ctlText.Value) End If End IfSub