Query to replace text specific Charcters

  • Thread starter Thread starter Craig Ferrier
  • Start date Start date
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.
 
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])
 
Back
Top