Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating ListBox

Status
Not open for further replies.

tbellomo

Technical User
Jan 28, 2002
73
US
Hello,
I'm trying to creat a "search form" in my database. I would like to use the entry in one textbox as the criteria for the list box. So if the user types "f" the listbox will populate with the records that begin with "f". if they then type "o", i would like it to limit more to only records beginning with "fo" and so on. I'm pretty close on how to do it, i just can't seem to find the right even to trigger it.
I tried: On Change - grab value in text box and store in a global, but it doesn't grab the value that i enter, because it hasn't been updated yet... it seems like the only event that would work would be the after update, but that doesn't allow a very "fluid" way of updating, and I need it to update after each character is typed -- does anyon have an advice? THank you.

Tim
 
Unless you have a specific reason....can't you use a combobox instead....this functionality is already built into the combobox....there is even a property for the combobox to automatically open when gaining focus....so it can "mimic" the listbox look but still function as you want....Why reinvent the wheel???

But at least you are one the right track if you must use a list box.......You will have to capture and store into a text field or variable every keystroke, the requery the list box which should have a parameter query attached to it to accept the new variable string... Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCSA, CNA, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
it's for a production database, and to me, it doesn't seem like the combobox would be effective for what i need -- if there's two productions with the same name, i need to see the other details of the production -- it seems to me that with the combo, i would have to worry about them clicking on the wrong one, which would cause the list to close, and overall, would be more confusing for the user. Do you know which event i should use to capture the value into the variable. I can't seem to find one that will capture it correctly -- except for the timer, but that's just sloppy. Thanks for your speedy reply and encouragement though - thanks

tim
 
I don't see how having two of the same name can be a problem. If you are allowing duplicate entries, then even the list box will end up displaying both of this entries....and a combobox can display as much detail as a listbox can.....

That being said, if you really want the daunting task of creating your own dynamic filter, the two properties you should be looking at are the OnKeyDown (or OnKeyPress) of the lisbox, and KeyPreview of the form. The KeyPreview should be set to True (or Yes).

The KeyPreview simply allows the form to capture the key presses, the you will need to place all the code to make/append the variable (fill in the text box) and requery the listbox recordsource.....

Good Luck! Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCSA, CNA, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top