VBA IsNull Function
IsNull Description
Used to check for a NULL value.
Simple IsNull Examples
1 2 |
Dim a MsgBox IsNull(a) |
Result: False
1 2 3 |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Sub AllocateGSTTypeIfNull() Set dbs = CurrentDb Set rst = dbs.OpenRecordset("tblInvoices", dbOpenDynaset) With rst .MoveFirst .MoveLast 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 .MoveNext Loop 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!
Learn More!