[Last Call] Learn how to a build a cloud-first strategyRegister Now


Access VBA listbox value while still typing

Posted on 2012-08-19
Medium Priority
Last Modified: 2012-08-20
I have a form with a bound listbox, with only one column - a string field of job numbers.

While the user types I want to check whether there is no match, and give a message along the lines of "There is no match for this job."

For a text box I would have to use txtField.text on a key press event, as txtField.value does not yet have what has been typed.

For the listbox, the keypress event is being triggered, but cboList.text is still empty after typing my first character.

What should I use to find the value of the listbox so far, on each key press?

Thank you.
Question by:MonkeyPie
LVL 61

Assisted Solution

mbizup earned 750 total points
ID: 38310071
You can't do what you are asking with a listbox alone.  There is no text property for a listbox like there is for a textbox or combo.

You can however do something similar - filtering a listbox with a textbox using code that filters the listbox as the user types in the textbox, character by character.

The sample in this article has an example of this:


When the database opens to the main form, click the button in the bottom right corner for the listbox search demo.  The demo usies a combo box to catch the keystrokes, but a textbox could be used in the same manner.
LVL 52

Accepted Solution

Gustav Brock earned 750 total points
ID: 38310842
I believe both of your requests are dealt with here:


LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38313105
The Previous two Experts have got you covered..., so I don't want any points...

Just a note.

Anytime you want something to happen "as you type"
...it can takes a lot of resources.

If the list of values to search will remain relatively small, then no problem.

But as ( ...or if) the list grows, you may notice that it takes longer and longer to work because it has to search more and more records.


Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question