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

yunhsuan

Member
Local time
Today, 18:30
Joined
Sep 10, 2021
Messages
54
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: 211

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 10:30
Joined
Jul 9, 2003
Messages
16,244
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.....
 

yunhsuan

Member
Local time
Today, 18:30
Joined
Sep 10, 2021
Messages
54
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.....
Yes, I want. I have sent you a pm. Thank you!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:30
Joined
May 7, 2009
Messages
19,169
see this discussion.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:30
Joined
May 7, 2009
Messages
19,169
another sample.
 

Attachments

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

Users who are viewing this thread

Top Bottom