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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with "Like" operator-- VB 6 with Access database 1

Status
Not open for further replies.

PeterS

Technical User
Jun 1, 2001
18
0
0
US
I'm trying to use the "Like" operator. "Like" works as expected in an Access query, but when I try to use it in VB code it returns only an exact match. For example,
Code:
 Like 'John Doe'
would return records with John Doe, but
Code:
 Like 'John D'
returns nothing, as do
Code:
 Like 'John D*'
and
Code:
 Like 'John Do?'
.
Code:
 Like 'J*'
also returns nothing. Needless to say, there are no records that are exactly 'J*', 'John D', 'John D*' or 'John Do?'.
Any work-arounds or explanations of what I'm doing wrong would be appreciated!
 
Try % instead of *, eg "Like 'John D%'"
 
I've just looked at some working code which uses the Like operator and your syntax looks the same. Must be something else about your SQL statement or VB syntax. Can you give more detail?
 
The "%" solved the problem! Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top