Access error reference
Access error 13: Type mismatch in VBA and queries (how to fix)
“Type mismatch”: VBA received a value it cannot convert to the type required. Text where the code expects a number, a badly written date, or an object from a different library than the one intended.
The message

Type mismatch
On a French Access: « Incompatibilité de type ». In a query, the equivalent has another number (3464, “Data type mismatch in criteria expression”).
Where it shows up
In VBA code: an assignment (lngQty = Me.txtQty), a calculation, a comparison, a function called with an argument of the wrong type, or Set rs = CurrentDb.OpenRecordset(…).
Common causes
- text in a numeric variable: “abc”, “12 kg” or an empty string
""put into aLong,IntegerorDouble; - a date written as text that VBA does not recognise as a date under the PC's regional settings;
Dim rs As Recordsetwith both the DAO and ADO references ticked: if ADO comes before DAO, the variable becomes an ADO Recordset, whileCurrentDb.OpenRecordsetreturns a DAO one.
How to reproduce and check it
- Click “Debug” and read the yellow line: the variable on the left gives the type expected.
- In the Immediate window (Ctrl+G), type
? TypeName(Me.txtQty)and? Me.txtQtyto see what actually arrives. - Try again with the control empty, then with malformed input (letters, a comma or a decimal point).
How to fix it
Check the input before converting: If Not IsNumeric(Me.txtQty) Then MsgBox "Invalid quantity.": Exit Sub, then lngQty = CLng(Me.txtQty). For a date: If IsDate(Me.txtDate) Then dtStart = CDate(Me.txtDate).
For Recordsets, name the library: Dim rs As DAO.Recordset, then Set rs = CurrentDb.OpenRecordset("Customers", dbOpenDynaset). Also give controls a format (number, date) and a validation rule: bad input is refused before it reaches the code.
What Auscult reports
The diagnostic records error 13 with the form, report or button that raises it, like the related type errors in queries. The report explains it as “A value is not of the kind expected: text instead of a number or a date, for example” and suggests fixing the value involved.
Related errors
- 94 — invalid use of Null, when the value is empty
- 91 — object variable not set
- 3075 — missing operator, a date or number in a regional format inside criteria
- The Access error reference, code by code