Your pictures are meaningless to me.
There are several ways to incorporate multiple selection into a filter. It is always useful to first consider what a finished, functioning filter should look like before attempting to put it together and integrate it using VBA.
Your version should look like this (alphanumeric content):
This means:
Include in query
Compared to other methods (use of Instr or LIKE), the use of an existing index on FieldX is supported here, so this method is a better choice.
There are several ways to incorporate multiple selection into a filter. It is always useful to first consider what a finished, functioning filter should look like before attempting to put it together and integrate it using VBA.
Your version should look like this (alphanumeric content):
Code:
=> for installation in VBA string with single quotes instead of the possible double quotes
WHERE FieldX IN ('a23', 'gg5', 'fd67')
Code:
For i = 0 To Me.CodigoMasa.ListCount - 1
If Me.CodigoMasa.Selected(i) Then
strCodigoMasa = strCodigoMasa & Chr(39) & Me.CodigoMasa.Column(0, i) & Chr(39) & ","
End If
Next i
Code:
sSQL = "SELECT * FROM TableY WHERE FieldX IN (" & strCodigoMasa & ")"
Compared to other methods (use of Instr or LIKE), the use of an existing index on FieldX is supported here, so this method is a better choice.
Last edited: