Return to VBA Code Examples

VBA IsNull Function

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on July 19, 2021

IsNull Description

Used to check for a NULL value.

Simple IsNull Examples

Dim a
MsgBox IsNull(a)

Result: False

Dim a
a = Null
MsgBox IsNull(a)

Result: True

IsNull Syntax

In the VBA Editor, you can type¬† “IsNull(” to see the syntax for the IsNull Function:

The IsNull function contains an argument:

Expression: An expression that will be tested.

IsNull Function Access VBA

The IsNull function works the same in Access VBA as it does in Excel VBA.

It is useful to check for a NULL value in a RecordSet Object.

Sub AllocateGSTTypeIfNull()
   Set dbs = CurrentDb
   Set rst = dbs.OpenRecordset("tblInvoices", dbOpenDynaset)
   With rst
      Do Until .EOF = False
'if GST Type is null then allocate 1 to it.
         If IsNull(rst.Fields("GSTType")) = True Then
            rst.Fields("GSTType") = 1
         End If
  End With
End Sub


VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as

Learn More!

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples