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!

Passing a Wildcard 1

Status
Not open for further replies.

cwadams

Technical User
Apr 9, 2007
26
US
I am using Access2003 and in VBA I have a NBHD of RJA. In the condition of my query,I want to query from the table all NBH that are like the first character that matches frmMyForm.NBH So I want to see all NBH that start with the letter R, regardless of length.
Suggestions for the syntax?

strSQL="SELECT MyTable.Nbhd FROM MyTable " & _
"WHERE ((MyTable.Nbhd) Like Left(([Forms]![frmMyForm]![Nbhd],1))& "*");
 
Code:
strSQL="SELECT Nbhd FROM MyTable WHERE Nbhd Like '" & Left(Forms!frmMyForm!Nbhd, 1) & "*'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
When I write the above code I get a Err # 13 Type Mismatch error. solution?
 
Which line of code is highlighted when in debug mode ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
When I have my original line it works with no error reporting.
"Where " & _
"((CompSales.Nbhd) Like [Forms]![frmSubject]![Nbhd]) AND" & _

But the new line crashes and reports: type mismatch
"Where " & _
"((CompSales.Nbhd) Like (Left([Forms]![frmSubject]![Nbhd], 1) & " * " )) AND" & _
 
Your code is quite different from mine ...
What about this ?
Code:
"Where " & _
"((CompSales.Nbhd) Like '" & Left(Forms!frmSubject!Nbhd, 1) & "*') AND" & _


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I tried your line of code and it kept erroring out and saying data mismatch. So I used a single quote around wildcard and it works. Thanks for the quick reply and helpfulness. I was running out of ideas.

"((CompSales.Nbhd) Like (Left([Forms]![frmSubject]![Nbhd], 1) & '*' )) AND" & _
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top