Query to replace text specific Charcters

C

Craig Ferrier

I am trying to do a select query with criteria to find certain characters.
These characters include * # ?.

I want to find accounts with 123#456, or 123*456, or 123?456

I need to write this into an sql statement

Dim strSQL as string
strSQL = "SELECT Table.Field FROM Table WHERE Table.Field Like ....

How can i do this?
Also Can i put a Chr( ) reference inside the query.
 
A

Allen Browne

I take it you want to find fields that have the literal asterisk, hash, or
question mark character?

Place the special characters in square brackets, e.g.:
"123[#]456"

You can use Chr() in a query if you need to. This example finds fields that
have an embedded carriage return:
Like "*" & Chr(13) & Chr(10) & "*"

In general, it's preferable to avoid calls to VBA functions if there is a
way to do it simply using SQL. For example, use:
WHERE [Field1] Is Null
rather than
WHERE IsNull([Field1])
 

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