Solved How to make combo have selectize fn in form? (1 Viewer)

yunhsuan

Member
Local time
Tomorrow, 06:16
Joined
Sep 10, 2021
Messages
52
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:
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
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!
 

Attachments

  • test.accdb
    976 KB · Views: 109

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 23:16
Joined
Jul 9, 2003
Messages
14,519
My "Nifty Search Form" might be of interest. It uses text boxes, not combos.



If you would like a free copy, send me a pm (private message) and I will explain how you can get a free copy.....
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:16
Joined
May 7, 2009
Messages
16,419
see this discussion.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:16
Joined
May 7, 2009
Messages
16,419
another sample.
 

Attachments

  • sample combo filter as you type.accdb
    1.1 MB · Views: 114

Users who are viewing this thread

Top Bottom