This is the code I have used for multi-criteria
Code:
If Me.m1.Value <> "" Then
If Len(Trim(Nz(Me.m1, ""))) > 0 Then
strFilter = strFilter & " AND " & "(" & "vehicletyp Like ""*" & Me.m1 & "*"" or "
End If
If Len(Trim(Nz(Me.m2, ""))) > 0 Then
strFilter = strFilter & "vehicletyp Like ""*" & Me.m2 & "*"" or "
End If
If Len(Trim(Nz(Me.m3, ""))) > 0 Then
strFilter = strFilter & "vehicletyp Like ""*" & Me.m3 & "*"" or "
End If
If Len(Trim(Nz(Me.m4, ""))) > 0 Then
strFilter = strFilter & "vehicletyp Like ""*" & Me.m4 & "*"" or "
End If
If Len(Trim(Nz(Me.m5, ""))) > 0 Then
strFilter = strFilter & "vehicletyp Like ""*" & Me.m5 & "*"" or "
End If
If Len(Trim(Nz(Me.m6, ""))) > 0 Then
strFilter = strFilter & "vehicletyp Like ""*" & Me.m6 & "*"" or "
End If
If Len(Trim(Nz(Me.m7, ""))) > 0 Then
strFilter = strFilter & "vehicletyp Like ""*" & Me.m7 & "*"" or "
End If
If Len(Trim(Nz(Me.m8, ""))) > 0 Then
strFilter = strFilter & "vehicletyp Like ""*" & Me.m8 & "*"" or "
End If
If Len(Trim(Nz(Me.m9, ""))) > 0 Then
strFilter = strFilter & "vehicletyp Like ""*" & Me.m9 & "*"" or "
End If
If Len(Trim(Nz(Me.m10, ""))) > 0 Then
strFilter = strFilter & "vehicletyp Like ""*" & Me.m10 & "*"" AND "
End If
If Len(Trim(strFilter & "")) > 0 Then
strFilter = Left(strFilter, Len(strFilter) - 5) & ")"
End If
End If
Me.Filter = strFilter
Me.FilterOn = True
And this is how I imagine the future code to work:
Code:
Private Sub multi_Click()
Dim strSearch As String
Dim j
strSearch = Split([Me.multit], [,])
...
If Len(Trim(strSearch & "")) > 0 Then
strSearch = Left(strSearch, Len(strSearch) - 5) & ")"
End If
End If
Me.Filter = strSearch
Me.FilterOn = True
End Sub
I am obviously lacking the complete middle part. I would guess, that I'll need to create a loop function, but am still a little bit stuck..