Hello all...New to this forum, old to Access and new to VBA...
Need help using multiple multi-select list boxes to filter a form. When I use the following code to filter using a single numerical list box (all list boxes are Multiselct Simple), everything is good.
Dim varitem90 As Variant
Dim Year As String
For Each varitem90 In Me.List90.ItemsSelected
Year = Year & Me.List90.ItemData(varitem90) & ","
Next varitem90
'Strip off the ending comma
Year = Left(Year, Len(Year) - 1)
'Turn it into an IN clause
Year = "year_is IN (" & Year & ")"
DoCmd.ApplyFilter "[year_is]", Year
When I use the following to filter using a single text list box, everything is good.
Dim varitem100 As Variant
Dim TRIM As String
For Each varitem100 In Me.List100.ItemsSelected
TRIM = TRIM & "'" & Me.List100.ItemData(varitem100) & "',"
Next varitem100
'Strip off the ending comma
TRIM = Left(TRIM, Len(TRIM) - 1)
'Turn into IN clause
TRIM = "TRIM_ss IN (" & TRIM & ")"
DoCmd.ApplyFilter "[trim_ss]", TRIM
I need help combining these two so that the user can select items from both list boxes, then apply filters to the form for both.
Need help using multiple multi-select list boxes to filter a form. When I use the following code to filter using a single numerical list box (all list boxes are Multiselct Simple), everything is good.
Dim varitem90 As Variant
Dim Year As String
For Each varitem90 In Me.List90.ItemsSelected
Year = Year & Me.List90.ItemData(varitem90) & ","
Next varitem90
'Strip off the ending comma
Year = Left(Year, Len(Year) - 1)
'Turn it into an IN clause
Year = "year_is IN (" & Year & ")"
DoCmd.ApplyFilter "[year_is]", Year
When I use the following to filter using a single text list box, everything is good.
Dim varitem100 As Variant
Dim TRIM As String
For Each varitem100 In Me.List100.ItemsSelected
TRIM = TRIM & "'" & Me.List100.ItemData(varitem100) & "',"
Next varitem100
'Strip off the ending comma
TRIM = Left(TRIM, Len(TRIM) - 1)
'Turn into IN clause
TRIM = "TRIM_ss IN (" & TRIM & ")"
DoCmd.ApplyFilter "[trim_ss]", TRIM
I need help combining these two so that the user can select items from both list boxes, then apply filters to the form for both.