neilanjk
asked on
How to add an auto-complete textbox control to an MS Access Form?
Hi, in Access 2000, as text is typed into a text control, I would like to display a list of matching words populated from a 'lookup' table. Each time another character is typed, the list should be filtered accordingly. At any point, the user should be able to select from the list of matching words. Ideally, the same function should apply to every word that is typed in the text box, i.e., every time a space is detected. Alternatively, the selected word could be appended to a string in another textbox.
I have found similar functions for VB 6.0 and VB.net, but they don't seem to translate to MS Access.
The textbox should not flicker as each letter is typed.
Here's an example of what I am looking for:
If the lookup table contains the following words "Ape", "Apex", "Apple", if the user types "A", all three words would appear in a select list. When the user adds the letter "p", i.e., "Ap", all 3 words still display. When the user adds the letter "e", i.e., "Ape", only "Ape" and "Apex" appear. The user may then select from the list to chose "Apex". A space key is pressed and the user types "a", and again all 3 words would be displayed.
Thanks!
I have found similar functions for VB 6.0 and VB.net, but they don't seem to translate to MS Access.
The textbox should not flicker as each letter is typed.
Here's an example of what I am looking for:
If the lookup table contains the following words "Ape", "Apex", "Apple", if the user types "A", all three words would appear in a select list. When the user adds the letter "p", i.e., "Ap", all 3 words still display. When the user adds the letter "e", i.e., "Ape", only "Ape" and "Apex" appear. The user may then select from the list to chose "Apex". A space key is pressed and the user types "a", and again all 3 words would be displayed.
Thanks!
ASKER
Steve, I considered a combobox. If there's code to make it function as described above (more-or-less), that might serve the purpose. j=-
you don't need code for the combo box, just created using the wizard...it will ask you to either enter data or use a look up table
As ki_ki suggests,
Use the wizard
See how the combobox functions basically.
It is possible to add a feature that allows you to directly add new data to the combobox list. This has to be added with extra coding, but see how the combo works first
Steve
Use the wizard
See how the combobox functions basically.
It is possible to add a feature that allows you to directly add new data to the combobox list. This has to be added with extra coding, but see how the combo works first
Steve
neilanjk,
I played around with this for a while.
I have something that does what you want.....
But it is Brute Force and not very elegant.
But it does work!
If you are interested, I will post it.
I played around with this for a while.
I have something that does what you want.....
But it is Brute Force and not very elegant.
But it does work!
If you are interested, I will post it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Wow boag2000 some hefty work there! I'll have to have a look at it some time too
Steve
Steve
ASKER
Boag2000, I will give this a try and get back to you...thanks...Jeff
ASKER
Boag2000....this is actually quite ingenious. Using SendKeys "{F2}" and the Like [Forms]![frmSearchNames]![ cboSearchN ames] & "*" and setting the Autoexpand property to No are key to this approach. Nice job.
What would make it even 'sweeter' would be this (A mouseless approach to selecting the desired item would be key):
1) user narrows the list using the combobox
2) using the up and down arrow keys selects an item from the listbox
3) press the Enter-key to append the selected item to a string in another text box (therefore, building a string of words).
If the user typed a word that was not in the list, perhaps Ctrl-Enter or Shift-Enter could be used to append the word in the Combo box to the string of words.
I can probably figure this out, unless you have some other tricks up your sleeve.
Let me know, either way and I will accept your solution.
Thanks again, Jeff
What would make it even 'sweeter' would be this (A mouseless approach to selecting the desired item would be key):
1) user narrows the list using the combobox
2) using the up and down arrow keys selects an item from the listbox
3) press the Enter-key to append the selected item to a string in another text box (therefore, building a string of words).
If the user typed a word that was not in the list, perhaps Ctrl-Enter or Shift-Enter could be used to append the word in the Combo box to the string of words.
I can probably figure this out, unless you have some other tricks up your sleeve.
Let me know, either way and I will accept your solution.
Thanks again, Jeff
Thanks!
If you look at the time difference between my two posts, you can figure out how long it took me!!
DateDiff("h",[Post1],[Post 2])
The notes are written in a certain manner because I am a Teacher by trade.
I thougt about "Sweetening" it up a bit, but I had a headache already and I was getting sleeeeeepy!
:)
(There are tons of posts here, on how to add an Item to the combobox automatically)
I just wanted to see:
1. If it could be done (it sounded like it could)
2. If "I" could do it!
3. If it would be an Acceptable solution.
Just transplant it into your Application and have fun!
Glad I could help!!!
:)
If you look at the time difference between my two posts, you can figure out how long it took me!!
DateDiff("h",[Post1],[Post
The notes are written in a certain manner because I am a Teacher by trade.
I thougt about "Sweetening" it up a bit, but I had a headache already and I was getting sleeeeeepy!
:)
(There are tons of posts here, on how to add an Item to the combobox automatically)
I just wanted to see:
1. If it could be done (it sounded like it could)
2. If "I" could do it!
3. If it would be an Acceptable solution.
Just transplant it into your Application and have fun!
Glad I could help!!!
:)
ASKER
boag2000, Wow....you spent a bunch of time on this. Thanks, for your help. I am well on my way to adding the enhancements. If you ever take this challenge any further, let me know. Thanks, again, Jeff
Thanks, I probably will.
I am getting closer to "Master" level, when achieved I will put my email in my profile.
Take care!
I am getting closer to "Master" level, when achieved I will put my email in my profile.
Take care!
Jeffery,
Either I did something wrong or it won't work with Access 2013...
Either I did something wrong or it won't work with Access 2013...
post a database of what you tried and I'll have a look
FWIW, ...this works fine for me in Access 2013
NameSearch.accdb
NameSearch.accdb
you won't get everything you want with that but access comboboxes work very well
You may need to investigate the NotInList event if you need to add new items.
Steve