Results 1 to 4 of 4
  1. #1
    oakoen is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2009
    Posts
    15

    Filter List box using text box

    I have been googling this and have no luck getting anything to work.

    I have a list box (customer_name). When a name is selected the form reflects customers data. I would like to have a text box that users can type in and as they type the listbox filters upon what they have typed.

    Why am I having such a hard time with this?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    It's doable, but have you considered a combo instead of a list box? By default it will jump to the appropriate location in the list as the user types.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    oakoen is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2009
    Posts
    15
    Just found this and got it working.

    Private Sub filterby_Change()


    Dim sql As String

    'this will match any entry in the list that begins with what the user has typed in the FilterBy control
    sql = "SELECT customer_ID, customer_Name FROM Customer WHERE customer_Name Like '" & Me.filterby.Text & "*' ORDER BY customer_name"

    'if you want to match any part of the string then add wildcard (*) before the FilterBy.Text, too:
    'sql = "SELECT ColorID, ColorName FROM Colors WHERE ColorName Like '*" & Me.FilterBy.Text & "*' ORDER BY ColorName"

    Me.List51.RowSource = sql

    End Sub

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Like I said, it's doable. From a user perspective, I believe the combo is easier. With this, I have to type in the textbox and then switch to the mouse to select from the listbox. With the combo, I can keep my hands on the keyboard (you can tell I work with data entry people a lot).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Filter available values in a drop down list
    By petitmorsalin in forum Access
    Replies: 1
    Last Post: 12-13-2010, 09:39 AM
  2. Replies: 1
    Last Post: 11-23-2010, 01:30 PM
  3. Filter by combo box & text box?
    By sparkyboy2406 in forum Forms
    Replies: 2
    Last Post: 02-24-2010, 04:20 PM
  4. Filter non-text data
    By bdriscoll in forum Access
    Replies: 2
    Last Post: 09-25-2009, 05:49 PM
  5. Replies: 1
    Last Post: 03-01-2009, 09:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums