Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    List - Find As You Type (2003)

    I have a list on my form with a query as the source...basically SELECT <3 fields> FROM <theTable>

    I also have a text box that is used for limiting the above list. I want the users to type in the text box and each time they press a key, the SQL changes so as to limit the data in the list.

    I've tried to put the following code in a few places, but no luck.
    <pre>Dim strSQL As String
    strSQL = "SELECT * FROM tblInventory WHERE in_title like '*" & Me.txtTitle & "*'"
    Me.List0.RowSource = strSQL
    Me.List0.Requery</pre>


    Unfortunately, it does not work as nothing seems to see the changes in me.txtTitle.

    Any pointers?

    Thanks!
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: List - Find As You Type (2003)

    You need to put this code in the On Change event of the txtTitle text box, and you must use the .Text property of the text box:
    <code>
    strSQL = "SELECT * FROM tblInventory WHERE in_title like '*" & Me.txtTitle.Text & "*'"
    </code>
    Me.txtTitle is the "stored" value of the text box, and Me.txtTitle.Text is the value as it is being typed by the user. The .Text property is only available when the text box has the focus, at other times referring to it will cause an error.

  3. #3
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List - Find As You Type (2003)

    Thanks Hans!

    I had tried code in the Change event, but t was the .text that made the difference.

    I was under the impression that .text was the default and it would work. Thanks for showing me the way!
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: List - Find As You Type (2003)

    > I was under the impression that .text was the default

    No, the Value property is the default property of a control.

Posting Permissions

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