Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 656
  • Last Modified:

"Adodc1.Recordset.Filter =" Help

I am currently filtering a recordset with the following:
----Recordset.Filter = "Customer like '" & cust & "'"
Where cust is my variable from an InputBox.
As long as I input the customers name exactly I get the desired results, however I would like be able to modify this for the filter to only match a portion of what I put in. Such as "boo" would return boots, boom etc..
Thanks,

0
fanguru1
Asked:
fanguru1
  • 3
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
(A quick stab) try Recordset.Filter = "Customer like '*" & cust & "*'"
0
 
fanguru1Author Commented:
If I use * or % and put in the complete first name I get the listing I am looking for. But I would like to search on the first few characters.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>I would like to search on the first few characters.
In that case you can avoid Like and use Recordset.Filter = "Left(Customer, 5)=cust"

Replace 5 with the number of leftmost characters you want to filter by.  
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
... slight correction...

Recordset.Filter = "Left(Customer, 5)='" & cust & "'"
0
 
leonstrykerCommented:
You can use a combination of wildcard and fixed.  Try this, assuming cust is 'boo', then this should give you boots, boom etc..

Recordset.Filter = "Customer like '" & cust & "%'"

Leon
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now