I am looking for code "want to filter combo-box (drop down data) by key word while typing". On a form I have three comboboxes. 1) for Articles 2) for Company 3) for Catalogues
I was able to do this search filter for one combobox (Articles), but dont know how to change it for the other two comboboxes on the same form. Example Picture (what I want):
I have used the following code for this. (1) 1st Public Sub FilterComboAsYouType(combo As ComboBox, defaultSQL As String, lookupField As String) (2) on particular combobox change envent.
Then combobox event on Change
Now the problem is , above 1st code "FilterComboAsYouType etc" is fixed with "Article" combobox. I dont know how to make this possible for the other two comboboxes on the same form 1) company 2) Catalogue.
I tried different ways, it did not work. I need expert opinion. Thanks
I was able to do this search filter for one combobox (Articles), but dont know how to change it for the other two comboboxes on the same form. Example Picture (what I want):
I have used the following code for this. (1) 1st Public Sub FilterComboAsYouType(combo As ComboBox, defaultSQL As String, lookupField As String) (2) on particular combobox change envent.
Code:
Public Sub FilterComboAsYouType(combo As ComboBox, defaultSQL As String, lookupField As String)
Dim strSQL As String
If Len(Article.Text) > 0 Then
strSQL = defaultSQL & " WHERE " & lookupField & " LIKE '*" & Article.Text & "*'"
Else
strSQL = defaultSQL 'This is the default row source of combo box
End If
Article.RowSource = strSQL
Article.Dropdown
End Sub
Code:
Private Sub Article_Change()
FilterComboAsYouType Me.Article, "SELECT * FROM ArticleNameTbl", "ArticlesName"
End Sub
I tried different ways, it did not work. I need expert opinion. Thanks