Access error reference
Access error 94: “Invalid use of Null” in VBA, causes and fix
A button works as long as everything is filled in, then stops on “Invalid use of Null” as soon as a control is left empty. The VBA code received Null, the value of an empty control or field, where it expected text, a number or a date.
The message

Invalid use of Null
On a French Access: « Utilisation incorrecte de Null ». The message names nothing: the line highlighted in yellow in the VBA editor, after clicking “Debug”, tells you where.
Where it shows up
In the code of a button, a form event or a function: strName = Me.txtName, lngId = DLookup(…), CLng(Me.cboCustomer), rs!EndDate put into a Date variable, or a value passed to a function that does not accept Null.
Common causes
- a text box or combo box left empty: its value is Null, and a
String,Long,DateorBooleanvariable cannot hold it; - an empty field in the table (
rs!Phone,Me!LeaveDate) read into a typed variable; - a
DLookup,DMaxorDFirstthat finds nothing: it returns Null, not zero or an empty string; - a conversion:
CStr,CLng,CDateorCInton a Null value also raise error 94.
How to reproduce and check it
- Note the form and the button, then try again leaving each control the code reads empty.
- Click “Debug”: the yellow line shows the variable receiving the value.
- In the Immediate window (Ctrl+G), type
? IsNull(Me.txtName)or? IsNull(DLookup("Id", "Customers", "Code='A1'"))to see the Null value.
How to fix it
First decide what an empty control means: refuse the action, or use a default value. To refuse, test before use: If IsNull(Me.cboCustomer) Then MsgBox "Choose a customer.": Exit Sub.
For a default value, Nz replaces Null: strName = Nz(Me.txtName, ""), lngId = Nz(DLookup("CustomerID", "Customers", "Code='A1'"), 0). A Variant variable accepts Null, but only pushes the problem further down the code.
What Auscult reports
The diagnostic tries the database's forms and buttons in Access, on a copy, and records error 94 with the form or button that raises it. The report explains it as “The code found an empty field where it expected a value” and suggests handling the case of a field left empty.
When the error only comes from a condition (a control not filled in, an empty table on the copy), the report files it as a conditional fault: “fails if …”, with the condition explained.
Related errors
- 13 — type mismatch, when the value is not empty but of the wrong kind
- 3075 — missing operator, the same empty control concatenated into SQL criteria
- 3021 — no current record
- The Access error reference, code by code