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

HELP!! Query "LIKE" operative use!

Status
Not open for further replies.

FredPeters

IS-IT--Management
Apr 30, 2002
10
CA
I am using a form to input a string to send to the query to produce names that have the queried string inside. eg Input pet to get Peters, Petrie Gepetto Trumpet etc. I'm going crazy trying to get the syntax using both % and * wildcards. The Access and VBA help examples aren't producing results. I can send the whole name and get results when the query is set for complete, but no partials.

HELP
Fred
 
Access uses * as the wild card
Might also want to make sure you are forcing everything to UpperCase (or Lower) when comparing - Just in case

Dim strName as String
Dim strSQL as String

strName = UCase(UserForm1.TextBox1.Text)

strSQL = "Select * from YourTable Where UCase(fldName) Like *" & strName & "*"


Maybe attach the SQL you are using if this does not work
 
Oops sorry - I think there should be single quotes in that previous SQL statement as well

example:
strSQL = "Select * from YourTable Where UCase(fldName) Like '*" & strName & "*'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top