"Adodc1.Recordset.Filter =" Help

Posted on 2005-04-11
Last Modified: 2013-12-25
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..

Question by:fanguru1
    LVL 65

    Accepted Solution

    (A quick stab) try Recordset.Filter = "Customer like '*" & cust & "*'"

    Author Comment

    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.
    LVL 65

    Expert Comment

    by:Jim Horn
    >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.  
    LVL 65

    Expert Comment

    by:Jim Horn
    ... slight correction...

    Recordset.Filter = "Left(Customer, 5)='" & cust & "'"
    LVL 29

    Expert Comment

    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 & "%'"


    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Problem to copy file 7 43
    Controlling which port to download from 4 51
    Problem to skip loop 6 40
    Excel object stays open 19 56
    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now