DB Query has Type mismatch in expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The 'type mismatch in expression' occurs in a query field whose criteria is [Forms]![frmEvalTest]![cboEvalSelectName
frmEvalTest and cboEvalSelectName are both correct
I get the same error whether I search on the ID field (numeric) or the name field (text)
Is there a syntax error in the expression
Any suggestions will be greatly appreciated.
 
'Type mismatch' usually means you're comparing data
somewhere and the data types don't match. This can happen
when you're using a text string as criteria for a numeric
field, even if the values match.

When you make a selection in a ComboBox, it only stores
one value, even if three or four are pulled and displayed.
From your description, my guess is [cboEvalSelectName]
pulls both the ID field (which is hidden) and the Name
(which is displayed) and stores the value of the ID field,
when you're trying to use the Name. Double check the
BoundColumn property of the ComboBox.

Two potential fixes:
Change the BoundColumn property to store the Name instead of the ID
Change the query and use [Forms]![frmEvalTest]!
[cboEvalSelectName] as the criteria for the ID field
instead of the name

Hope this helps!

Howard Brody

-----Original Message-----
The 'type mismatch in expression' occurs in a query field
whose criteria is [Forms]![frmEvalTest]![cboEvalSelectName]
frmEvalTest and cboEvalSelectName are both correct.
I get the same error whether I search on the ID field
(numeric) or the name field (text).
 
I've also seen this when a calculated field is using a VBA function, and the
value of the function's argument (usually a field from a table) is Null, and
that function cannot handle Null as an argument.

--
Ken Snell
<MS ACCESS MVP>

Howard Brody said:
'Type mismatch' usually means you're comparing data
somewhere and the data types don't match. This can happen
when you're using a text string as criteria for a numeric
field, even if the values match.

When you make a selection in a ComboBox, it only stores
one value, even if three or four are pulled and displayed.
From your description, my guess is [cboEvalSelectName]
pulls both the ID field (which is hidden) and the Name
(which is displayed) and stores the value of the ID field,
when you're trying to use the Name. Double check the
BoundColumn property of the ComboBox.

Two potential fixes:
Change the BoundColumn property to store the Name instead of the ID
Change the query and use [Forms]![frmEvalTest]!
[cboEvalSelectName] as the criteria for the ID field
instead of the name

Hope this helps!

Howard Brody

-----Original Message-----
The 'type mismatch in expression' occurs in a query field
whose criteria is [Forms]![frmEvalTest]![cboEvalSelectName]
frmEvalTest and cboEvalSelectName are both correct.
I get the same error whether I search on the ID field
(numeric) or the name field (text).
Is there a syntax error in the expression?
Any suggestions will be greatly appreciated.
.
 
Thanks for your suggestions, they are good and I have filed them away for reference.
The actual problem was elsewhere. In the relationships window, I had dragged an ID to another table and equated it to a text field. The query accessed this link, which blew up.
 
Back
Top