Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Text box filter listbox not working (2000)

    I'm creating a new database, and I'm trying to use a text box to filter a list box. The list box refers to the form's text box in criteria

    Like [forms]![frmLookup]![txtSearch] & "*"

    And the text box's Change event includes

    Me!lstNames.Requery

    but nothing happens. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text box filter listbox not working (2000)

    I think you have to surround this wit double quotes :
    "Like " & Chr(34) & [forms]![frmLookup]![txtSearch] & "*" & Chr(34)
    Francois

  3. #3
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text box filter listbox not working (2000)

    Francois,
    When I do that, nothing shows in my list box. <img src=/S/aflame.gif border=0 alt=aflame width=16 height=16>

    Is it possible I'm missing a reference or something?
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text box filter listbox not working (2000)

    What is the exact code you use to change the rowsource of the list box in the after update of the textbox ?
    Francois

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text box filter listbox not working (2000)

    I just test the following line and it works for me.
    SELECT NAMEN.NAAM FROM NAMEN WHERE (((NAMEN.NAAM) Like [forms]![form3]![text2] & "*"));

    This is a sample of changing the rowsource by code :
    <pre>Private Sub Text2_AfterUpdate()
    Dim strSQL As String
    strSQL = "SELECT NAMEN.NAAM FROM NAMEN WHERE NAMEN.NAAM Like " & Chr(34) & Me.Text2 & "*" & Chr(34)
    Me.List0.RowSource = strSQL
    Me.List0.Requery
    End Sub</pre>

    Francois

  6. #6
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text box filter listbox not working (2000)

    <P ID="edit" class=small>(Edited by NYIntensity on 09-Sep-05 20:14. Added example)</P>Francois,
    I don't think I'm changing the rowsource - just filtering it.

    Private Sub txtSearch_Change()
    Me!lstNames.Requery
    End Sub

    List box RowSource:
    SELECT tblDictionary.CORRECT, tblDictionary.WRONG FROM tblDictionary WHERE (((tblDictionary.WRONG) Like [forms]![frmLookup]![txtSearch] & "*"));
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

  7. #7
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text box filter listbox not working (2000)

    I just note that you are doing the requery in the Change Event.
    Modify this and set it in the After Update Event of the text box.
    Francois

  8. #8
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text box filter listbox not working (2000)

    Francois,

    While steaming over this, I realized that all I needed to do was add .[text] to my original query data....so I am using

    txtSearch After Update
    Me!lstNames.Requery


    and the row source
    Like [forms]![frmLookup]![txtSearch].[text] & "*"

    And it works fine. Thanks for helping me!
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •