Using Textbox to search for an item from a ListBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tara99
    New Member
    • Oct 2006
    • 106

    Using Textbox to search for an item from a ListBox

    I have a list box called CCList which displays a field form table based on a query
    Code:
    SELECT CC.table1 FROM table1 ORDER BY CC.table1;
    Each CC consists of 5charecter starting with a letter the rest is number (e.g.: A0214. D2145,Y0568 and etc...)

    The list box is huge so the user needs to scroll down to find what they looking for.
    To make it easier for the user I have created a textbox to perform a search.
    I want the user to enter either the first letter or the item number in the text box and based on the user input the CCList should jump to that (input) item.

    I was just wondering how I can do this.
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Similar answer to previous question Tara.

    Set the list box row source to the following:

    Code:
    SELECT CC.table1 FROM table1 
    WHERE CC.table1 Like [Forms]![FormName]![textboxName]*
    ORDER BY CC.table1;
    Put the Me.listboxName. Requery statement either in the after update event of the textbox or behind a command button.

    Mary

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Wouldn't it be easier for the user if a combobox was used with Auto Expand set to YES?

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        Originally posted by missinglinq
        Wouldn't it be easier for the user if a combobox was used with Auto Expand set to YES?
        For the first part Yes.
        For the second that wouldn't help - good point to bring up though :).

        Comment

        • tara99
          New Member
          • Oct 2006
          • 106

          #5
          Originally posted by mmccarthy
          Similar answer to previous question Tara.

          Set the list box row source to the following:

          Code:
          SELECT CC.table1 FROM table1 
          WHERE CC.table1 Like [Forms]![FormName]![textboxName]*
          ORDER BY CC.table1;
          Put the Me.listboxName. Requery statement either in the after update event of the textbox or behind a command button.

          Mary
          Mary
          I put
          Code:
          SELECT CC.table1 FROM table1 
          WHERE CC.table1 Like [Forms]![FormName]![textboxName]*
          ORDER BY CC.table1;
          Behind the row source of my list box, it complains about syntax error which is the [textboxName]* when I delete the sign * than it doesn't display any thing the list.
          It just wait for the user to enter something in the textbox if it exist than you will see it on the List box.
          /???

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Originally posted by tara99
            Mary
            I put
            Code:
            SELECT CC.table1 FROM table1 
            WHERE CC.table1 Like [Forms]![FormName]![textboxName]*
            ORDER BY CC.table1;
            Behind the row source of my list box, it complains about syntax error which is the [textboxName]* when I delete the sign * than it doesn't display any thing the list.
            It just wait for the user to enter something in the textbox if it exist than you will see it on the List box.
            /???
            Try this ...

            Code:
            SELECT CC.table1 FROM table1 
            WHERE CC.table1 Like [Forms]![FormName]![textboxName] & "*"
            ORDER BY CC.table1;

            Comment

            • tara99
              New Member
              • Oct 2006
              • 106

              #7
              Originally posted by mmccarthy
              Try this ...

              Code:
              SELECT CC.table1 FROM table1 
              WHERE CC.table1 Like [Forms]![FormName]![textboxName] & "*"
              ORDER BY CC.table1;
              Thanks Mary

              It is fine now

              Comment

              • MMcCarthy
                Recognized Expert MVP
                • Aug 2006
                • 14387

                #8
                Originally posted by tara99
                Thanks Mary

                It is fine now
                That's great Tara

                Mary

                Comment

                Working...