Data type mismatch in criteria expression

T

Tcs

I have a select query with only two fields that I want to use to get a count of
the second field, grouped by the first field:

Ward PropCode
---------- ----------
Group By Count

This runs fine when I do NOT specify what PropCode I want. As soon as I add
"AP" to the criteria, I get this error msg:

"Data type mismatch in criteria expression."

I'm using data from a linked table (DB2 UDB on AS400). I've done this about 2
months ago, and I had no problems. I've searched this NG for the same error and
it would seem I have a field with a Null, but I can't find any record with a
Null.

Anyone have any thoughts/ideas?

Thanks in advance,

Tom
 
H

HCJ

Hi tcs,
I think you need two instances of PropCode in the
query; one to Group By, and the second to Count. You only
have the second instance. Add the criteria to the Group
By instance.

Hope this helps.
 
J

John Spencer (MVP)

If AP is a property code, then you need to add PropCode to your query a second
time and change it to a WHERE and then put your criteria against that. Right
now, Access is complaining because is has no idea how to match a COUNT (a
Number) to "AP" (a string).

Ward PropCode PropCode
---------- ---------- ----------
Group By Count Where

In the SQL window that would look something like

SELECT WARD, Count(PropCode) as Expr1
FROM SomeTableName
WHERE PropCode = 'AP'
GROUB BY Ward
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top