Hello!
There are several combos in the form of my database, and the combos are query to the datasheets. Because the list in datasheet is too long to let users find the correct one quickly, I hope users can find related name by just typing one or several words of the target name. Then, I found the module named "Selectize" on website and tried to apply it in my database. But, several problem was shown.
1. User would filled in OrderDate first, then OrderNo would be automatically created. Next, SupplierNo and ProjectNo would be chose. "Selectize" module applys to these two field. But, warning would be shown at the second step.
2. After I choose SupplierNo and ProjectNo in one form, the value of two fields would miss in previous records when the value of them is different with that in this form. (Just miss in the form but not in datasheet. They would show again when the report is reopened.)
3. Sometimes, the query source of the combos would somehow be changed to CStr([" & lookupField & "]) LIKE ""*" & combo.Text & "*""".
The code of "Selectize" module:
My test file is attached below.
How can I edit it to let the "Selectize" module went well in my database. Or is there other way to achieve the selectize fn, which I want.
Thanks for any suggestions in advance!
There are several combos in the form of my database, and the combos are query to the datasheets. Because the list in datasheet is too long to let users find the correct one quickly, I hope users can find related name by just typing one or several words of the target name. Then, I found the module named "Selectize" on website and tried to apply it in my database. But, several problem was shown.
1. User would filled in OrderDate first, then OrderNo would be automatically created. Next, SupplierNo and ProjectNo would be chose. "Selectize" module applys to these two field. But, warning would be shown at the second step.
2. After I choose SupplierNo and ProjectNo in one form, the value of two fields would miss in previous records when the value of them is different with that in this form. (Just miss in the form but not in datasheet. They would show again when the report is reopened.)
3. Sometimes, the query source of the combos would somehow be changed to CStr([" & lookupField & "]) LIKE ""*" & combo.Text & "*""".
The code of "Selectize" module:
Code:
Public Sub FilterComboAsYouType(ByRef combo As ComboBox, ByVal defaultSQL As String, ByVal lookupField As String)
Dim strSQL As String
If Trim(combo.Text & "") <> "" Then
strSQL = "SELECT * FROM (" & defaultSQL & ") WHERE CStr([" & lookupField & "]) LIKE ""*" & combo.Text & "*"""
Else
strSQL = defaultSQL 'This is the default row source of combo box
End If
combo.RowSource = strSQL
combo.Dropdown
End Sub
How can I edit it to let the "Selectize" module went well in my database. Or is there other way to achieve the selectize fn, which I want.
Thanks for any suggestions in advance!