Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using LIKE with single character wildcard

Status
Not open for further replies.

RichardF

Programmer
Oct 9, 2000
239
GB
Hi,

I am trying to using a single character wildcard operator in my SQL ::

cSQL = "select * from customers where TLA like 'R_S'"
rs.Open cSQL ...

this is fine.

however if i do :
cFilter = "TLA like 'R_S'"
rs.Filter = cFilter

then this does not work.

Any ideas ?

Thanks in advance.

 
SQL wildcard for single character is underscore '_' so if you are using SQL type syntax use underscore.

Access wildcard for single character is question mark '?' so using Access syntax (like Filter) change _ to ?
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
It still doesnt work .

im using VB6 and ADO 2.6.

heres the code...

' in this example FilterString is "TLA Like 'R?S'"
Public FilterResults(FilterString as string)
rsResults.Filter = FilterString
rsResults.MoveFirst
End Sub
 
You cannot use wildcards in the middle of the criteria string, only at the end or at the beginning and the end.

The following sentence is from the Microsoft ADO 2.6 help file (ado260.chm). you can get this file if you download the Microsoft Data Access Components SDK. You can find it at:
In a LIKE clause, you can use a wildcard at the beginning and end of the pattern (for example, LastName Like '*mit*'), or only at the end of the pattern (for example, LastName Like 'Smit*').
 
that feature really sucks.!

anyway thanks albert, now i will completely redesign my filter form !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top