Learn when you want, where you want with convenient online training courses. Sign up now!
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
Private Sub cmd_Filter_Click
me.Filter = fnMultiList(me.lst_FilterField)
me.filteron = Len(me.filter) > 0
Open in new window
Public Function fnMultiList(lst As ListBox, Optional SelectAll As Boolean = False, _
Optional UseColumn As Integer = -1) As Variant
Dim varItem As Variant
Dim lngItem As Long
Dim strDelimiter As String
fnMultiList = Null
'Determine how to delimit the list items
If UseColumn = -1 Then UseColumn = lst.BoundColumn - 1
If IsNumeric(lst.Column(UseColumn, Abs(lst.ColumnHeads))) Then
strDelimiter = ""
strDelimiter = Chr$(34)
'loop through the selected items in the list
If lst.MultiSelect = 0 And SelectAll = False Then
fnMultiList = lst.Value
For lngItem = 0 To lst.ListCount
If lst.Selected(lngItem) = True Or SelectAll Then
fnMultiList = (fnMultiList + ",") _
& strDelimiter & lst.Column(UseColumn, lngItem) _
'Strip trailing "," if there is one
If Right(fnMultiList, 1) = "," Then fnMultiList = Left(fnMultiList, Len(fnMultiList) - 1)
'Depending on the number of items selected, determine how the "list values" are returned
If Len(fnMultiList & "") = 0 Then
fnMultiList = " IS NOT NULL"
Select Case Len(fnMultiList) - Len(Replace(fnMultiList, ",", ""))
fnMultiList = " = " & fnMultiList
fnMultiList = " IN (" & fnMultiList & ")"
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.