Create a Text Box/List Box combination like the one in Windows Help. As you type in the Text portion of the Text Box, the List Box will scroll to whatever has been typed so far.
Create a Text Box/List Box combination.
Collapse
X
-
Tags: None
-
The standard Access Combobox control works this way with the AutoExpand property set to Yes, which is the default setting.
Welcome to Bytes!
Linq ;0)>
Moderator -
-
The combo box is very useful, but if you'd really like to do something like what you mentioned, you could try this. This will set up a list box which displays a list of items filtered by what you type into a text box.
Example: if you type "dog," the list box will display all items containing the word "dog," including "Doggy Bag," "Iams Dog Food" and "Bad Dog." A combo box would only show the items that start with "dog," i.e. "Doggy Bag."
Assume your search involves a field called txtSearchField in a table called tblMain.
On your form, create a text box called txtFinder, and a list box called lstPicker.
Set lstPicker's rowsource to
Then, put this code in txtFinder's On Key Up event.Code:SELECT txtSearchField FROM tblMain WHERE txtSearchField Like ("*" & [txtFinder] & "*") OR txtSearchField Like ([txtFinder] & "*") OR txtSearchField Like ("*" & [txtFinder])
I hope this works for you!Code:lstPicker.SetFocus lstPicker.Requery With txtFinder .SetFocus .SelStart = Len(.Text) End WithComment
-
Assuming the name of the ComboBox is cboTestBox, then the code
should do what you want if AutoExpand = True.Code:Private Sub cboTestBox_GotFocus() cboTestBox.Dropdown End Sub
I have seen other threads that discourage use of GotFocus/LostFocus, and maybe some other event can be used. I didn't try, but I did test the above code.Comment
Comment