2

I have the following Access query:

SELECT [city]
FROM [patient]
WHERE REPLACE([patient].[city],'  ',' ') LIKE 'San D*'

I'm relatively certain this used to work but now I get Data type mismatch in criteria expression.

Any ideas?

EDIT

Anyone willing to test the sql against their own data?

0

2 Answers 2

5

The problem turned out to be a null value in the column.

The solution is:

SELECT [city]
FROM [patient]
WHERE REPLACE(
  IIF(ISNULL([patient].[city]),'',[patient].[city])
  ,'  ',' ') LIKE 'San D*'
Sign up to request clarification or add additional context in comments.

1 Comment

That's quite helpful! Thanks!
3

Is the city stored as a string? If its stored as a number (perhaps as an fkey to another table) then this would make sense as you're using string operations on it.

Edit: Note to self: stop forgetting about Null values.

2 Comments

@ic3b3rg Are you absolutely sure it is a string? You have looked at the table itself in design view and ensured that a look-up table has not been used? I ask, because the query works for me.
@Remou The problem was a null value in the column - I added an answer with the solution.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.