'Data type mismatch in criteria expression' error in Count query



I'm new to Access so be gentle with me ;-) I'm currently doing a project
where I need to count the number of cities (in a 'City' field) which meet
particular city names. I've done a count query with the city name in the
criteria, but all I get is an error saying 'Data type mismatch in criteria
expression'. I'm not sure what I'm doing wrong as the City field is text and
I'm typing the city name correctly.
Any help would be appreciated.



Ken Snell [MVP]

If you're building the SQL statement directly, then you need to delimit the
city name value with ' characters:

SELECT Count(*)
FROM TableName
WHERE City = 'City Name';

The above applies as well when you create and apply any type of filter to a
query that does not have criterion in it.

If you're entering the city name in the Criteria: box while in the design
view of the query, then ACCESS usually will delimit the value with "
"City Name"

Tell us more details about how you're "doing" the query.

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