Skip to content
Auscultby NBIT
EN
Free diagnostic

Access error reference

Access error 3464: data type mismatch in criteria

A query, a filter or a DLookup stops on “Data type mismatch in criteria expression”. Access is comparing a field with a value of another type: text with a number, a date with a string. The code was often written for a field whose type has changed since.

The message

Microsoft Visual Basic box: “Run-time error '3464': Data type mismatch in criteria expression.”, with End, Debug and Help buttons
The real error box, captured in Access for Microsoft 365 in English: a VBA query compares the numeric ID field with the text '12'.

Run-time error '3464': Data type mismatch in criteria expression.

English Access

On a French Access: « Type de données incompatible dans l'expression du critère. » When the query is opened on screen rather than from code, the same message appears without the number.

Where it shows up

Wherever a criteria compares a field with a value: the Criteria row of a query, a WHERE clause built in VBA, DLookup, DCount, Me.Filter, rs.FindFirst, the criteria of DoCmd.OpenForm or DoCmd.OpenReport, and joins between two tables.

Common causes

  • a number wrapped in quotes: "[CustomerID]='" & Me.txtId & "'" while CustomerID is a Number field;
  • text without quotes: "[ZipCode]=" & Me.txtZip on a Short Text field, which Access reads as a number;
  • a date passed as text: "[OrderDate]='11/21/2026'" instead of a date between hash signs;
  • a lookup field: the table shows the label (“Boston”) but stores the number; the criteria compares that number with text;
  • a join between fields of different types (Short Text on one side, Number on the other), common after importing from Excel;
  • a calculated column that returns an error on some rows (CDate, CLng on an empty value) and is then filtered: the error only shows with certain data.

How to reproduce and check it

  1. Open the table in Design view and note the data type of the field in the criteria (and, on the Lookup tab, whether it is a lookup list).
  2. Print the criteria as Access receives it: Debug.Print strWhere just before the call, then read it in the Immediate window (Ctrl+G).
  3. Paste that criteria into a query in SQL view: if the error comes back, the comparison is the cause; if not, look at a join or a calculated column.

How to fix it

Match the value to the field type: nothing around a number, quotes around text (doubling any quote inside), hash signs around a date in mm/dd/yyyy format. For a lookup field, compare the bound column (the number), not the label. For a join, give both fields the same type.

What Auscult reports

The diagnostic records 3464 wherever Access returns it during the run, with the form, report, query or button that produces it; one cause is counted once. Without running anything, it also flags criteria written in a way that will fail — a text field compared with a number, a value concatenated without quotes — among the statements that will fail the day they are used.

The Access error reference, code by code

Frequently asked questions

Why does the error only appear on some records?

Because a calculated column or a conversion (CDate, CLng, Val) fails on some values only: an empty cell, text typed into a field meant for numbers. The query works as long as those rows are not in the result.

The criteria works in the query grid but fails in VBA: why?

In the query grid, Access adds the hash signs and quotes itself. In VBA you build the string: one quote too many or too few is enough to change the type of the value.

Should I change the field type in the table?

Rarely. Changing a type breaks the queries, relationships and code that use the field elsewhere. Fix the criteria first; change the type only if the field is genuinely wrong (a zip code stored as Number, for instance), then check everything that uses it.

Where are the other errors in your application hiding?

The diagnostic runs on your computer, on a copy of the application, without sending the data in your tables. The health grade and the summary are free.