How do I Autoselect listbox record by value entered in text box.

Prysson

Registered User.
Local time
Today, 13:04
Joined
Sep 23, 2002
Messages
45
Say I have a form with a List box that display last names. And there is a text box on the form where the user can enter in letters.

How can I autselect the records according to whats in the text field automatically.

Say the user enters in the letter H
Then the list field automatically moves down and selects the first H allowing the user to easily scroll through the rest of the H's...

Or maybe he enter Hi
Then the list box automaticall selects down to the first Hi listing.

Or if he enters hi then backspaces and enters he...then it would move up to the he.

All of this without ever actually having to click any buttons...
 
Try this code in the On Change event of the text box (using the correct list box name and text box name):-

-----------------------------
Private Sub textBoxName_Change()

Dim i As Integer
For i = 0 To Me.[listBoxName].ListCount - 1
If Me.[listBoxName].Column(0, i) Like Me.[textBoxName].Text & "*" Then
Me.[listBoxName] = Me.[listBoxName].Column(0, i)
Exit For
End If
Next

End Sub
-----------------------------

Hope it helps.
 
That works PERFECT!!!

That is cool.

Thanks a bundle for the help!
 
Jon_K, along these same lines I need to be able to preselect items from a list, but there will be no user input to identify what to select. I have specific items that will always need to be selected from the list, but give the user the ability to deselect them.

I know this is old and I really hope you are still part of the forums or that someone else can answer that question.

Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom