Full Version: Filtering Combobox
UtterAccess Forums > Microsoft® Access > Access Forms
Tiesto_X
Hi guys,

I have a Combobox that contains values of the companies.

For example, there is company called "K & K ELECTRONICS DOO" .
Is there chance that I cant type "ELECTRONICS" instead of "K & K" (first letters of the company name) and still get suggestion "K & K ELECTRONICS DOO" in Combobox.

Tnx!
pere_de_chipstick
Hi Tiesto

You can only type the FIRST characters of the string to get the autofill result, however you could use a separate text box and use code in the text box's on change event to amend the combo box row source to reflect entries that only have (e.g.) "electronics" in the text.

hth
Tiesto_X
Hi there,

Kinda was sure thats the only way.

If someone have some code, would be so helpful.

Tnx pere!
pere_de_chipstick
Hi Tiesto

in the text box's on change event try:
CODE
Dim strSQL as String
strSQL = "SELECT * FROM tblCompanies WHERE CompanyName Like '*" & Me.YourTextBoxName.Text & "*';"

Me!YourComboBoxName.RowSource = strSQL
Me!YourComboBoxName.Requery


Replacing the table, field and control names as appropriate for your db.

hth

PS:
I've always used this method in conjunction with a list box, rather than a combo box, as you can see the effect of the filtering as you type.

Cheers
Tiesto_X
Thank you sir, it works perfect! thanks.gif
pere_de_chipstick
yw.gif
Good luck with your project.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.