Results 1 to 15 of 15
  1. #1
    Join Date
    Jul 2007
    Posts
    29

    Unanswered: Look up while typing

    I want to have a combo box or other control if needed start looking up possible entries as soon some begins typing in it. Exactly what Outlook does when your entering a recipients name. I tried a whole bunch of different methods none were very successful. Can anyone point me in a more correct direction.

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Setting the AutoExpand property on a combo box to Yes should take care of that for you.
    Inspiration Through Fermentation

  3. #3
    Join Date
    Jul 2007
    Posts
    29
    That doesn't really work like I would like. For sake of example lets assume the box is the entry for last name. I have "Go" entered making "Gordon" the top entry and showing no other entries. I want the other entries to show and to be able to select from them using the arrow keys.

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    I don't follow...

    That's exactly how my combo boxes work. It moves towards whatever you're typing, but ALL values are available in the drop down list.
    Inspiration Through Fermentation

  5. #5
    Join Date
    Jul 2007
    Posts
    29
    Let me claify. In my example the other entries will show only after I have clicked on the arrow. And it will be the full list of possible names A-Z. I want it to expand while typing and to only show the entrys that match what what I have already entered. In this case Only last names starting with Go.

  6. #6
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    ooohhhh.... You want it to limit the list as you're typing. I know that's
    been addressed here before. Even did it myself a few years ago.
    I'll see if I can dig it up.
    Inspiration Through Fermentation

  7. #7
    Join Date
    May 2005
    Posts
    1,191
    Wouldn't you do something like the following on the keypress event?

    untested-code:
    Dim strSQL as string
    strSQL = "SELECT TblName.FldName FROM TblName"

    If Nz(me.CmbBoxName,"") <> "" Then
    strSQL = strSQL & " WHERE [FldName] = '" & me.CmbBoxName & "*'"
    End If

    strSQL = strSQL & ";"
    me.CmbBoxName.recordset = strSQL
    me.refresh


    EDIT: Fixed code error
    Last edited by nckdryr; 08-10-07 at 17:37.
    Me.Geek = True

  8. #8
    Join Date
    Mar 2007
    Posts
    277
    Maybe you will find this link useful.
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  9. #9
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Search Examples

    The one thing I haven't found in any search examples anywhere is the ability for the search box to handle spaces entered when using the OnChange event (or at least a method with only 2-3 lines of coding). Everything I've found has some complex method or issues a me.MySearchText.SelStart = me.MySearchText.SelLength which causes a problem if a space is entered (ie..entering "All State" truncates when you push the space after "All" which makes the search worthless) and every thing I could find had dozens of lines of complex code. Setting a complex sql statement or coding some other complex routine sounded unreasonable and I wanted to do it with a 1 simple query and only 2-3 lines of simple code with no complex functions.

    So I played around with setting a boolean value to true or false depending on if the spacebar is pushed in the OnKeyPress event for the searchbox. The OnChange event of the searchbox then simply looks at the boolean value and will ignore firing if a spacebar is pushed.

    On this search form it also automatically detects the email column of the listbox and is set up so you can quickly locate a name (such as in Outlook), and create an email with a few keystrokes. It can be easily modified to do anything such as go to the record selected.

    Look at the Sample Business Search Form 2 In this attachment to see how this works. I've also included Sample Business Search Form 1 which is a typical search where you can tab through alphabetical letters as well as some other goodies which are worth looking at.

    Sample Business Search Form 4 lets you select the field you want to search on with the typing of every character. It also lets you use the up/down arrow keys once you've tabbed into the listbox (ie..no mouse clicking needed).

    Again, there's NO complex or dozen lines of code in any of this (except the code used for each alphabetical letter buttons which is very straightforward and a simple requery.) Since there are A-Z buttons, the code would obviously be longer due to each letter.
    Attached Files Attached Files
    Last edited by pkstormy; 08-11-07 at 12:32.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  10. #10
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388
    Using the Dropdown method in the Got Focus event of your combo box

    When the user enters the combo box the list is displayed and as the user starts typing the list is filtered, for spaces the user presses the space bar then the next character and the list keeps on filtering .

    I have attached a sample demo using a form called frm_test
    Attached Files Attached Files

  11. #11
    Join Date
    Jul 2007
    Posts
    29
    Thanks for all the great replies... Looks like everything I need is here.

  12. #12
    Join Date
    Jun 2004
    Location
    Seattle, WA
    Posts
    601
    Something like this was covered a few weeks back.
    http://www.dbforums.com/showthread.php?t=1620209
    Look at Paul's form in post 8 or so.
    Ryan
    My Blog

  13. #13
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Thanks Ryan, - I've been going in so many directions, I forget about these. I should try and consolidate some of these for the code bank. I remember those posts now though (my headache just came back). He wasn't ever checking the samples I uploaded to him. Once he finally checked them, he realized it was exactly what he wanted (which I did in his own mdb.)
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  14. #14
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Lol, don't say I didn't tell you so
    George
    Home | Blog

  15. #15
    Join Date
    Jun 2004
    Location
    Seattle, WA
    Posts
    601
    haha yeah I remember that. He was like just give me the code! And we were all like just open the attachment, it's done for you!
    Ryan
    My Blog

Posting Permissions

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