I have a continuous form that shows 1000 or so records that I am trying to filter based on Combo Boxes. I'm using the me.filter property of the form and it will filter it just takes a minute or two. The form is bound to a Query pulling from two tables and the fields I'm filtering on are indexed. If I have the filter criteria in the form set when I open the form, it opens quick. Its when i change it that i have issues. I have tried adding me.filteron = false and me.filteron=true and that hasn't seemed to help. Below is the sub that I'm calling to change the filter.
Code:
Sub FilterMe()
Dim Video As String
Dim HSD As String
Dim RealTCs As String
Dim FollowUp As String
Video = "(((TroubleCalls.Status) Not Like 'C*' And (TroubleCalls.Status) Not Like 'Follow*') AND " & _
"((TroubleCalls.[WO Reason Code]) Not Like 'B*' Or " & _
"(TroubleCalls.[WO Reason Code]) Not Like 'DC*' Or " & _
"(TroubleCalls.[WO Reason Code]) Not Like 'DD*' Or " & _
"(TroubleCalls.[WO Reason Code]) Not Like 'EI*' Or " & _
"(TroubleCalls.[WO Reason Code]) Not Like 'EN*' Or " & _
"(TroubleCalls.[WO Reason Code]) Not Like 'I*' Or " & _
"(TroubleCalls.[WO Reason Code]) Not Like 'MA*' Or " & _
"(TroubleCalls.[WO Reason Code]) Not Like 'MS*' Or " & _
"(TroubleCalls.[WO Reason Code]) Not Like 'ST*'))"
HSD = "(((TroubleCalls.Status) Not Like 'C*' And (TroubleCalls.Status) Not Like 'Follow*') AND " & _
"((TroubleCalls.[WO Reason Code]) Like 'EI*' Or " & _
"(TroubleCalls.[WO Reason Code]) Like 'EN*' Or " & _
"(TroubleCalls.[WO Reason Code]) Like 'I*' Or " & _
"(TroubleCalls.[WO Reason Code]) Like 'MA*' Or " & _
"(TroubleCalls.[WO Reason Code]) Like 'MS*' Or " & _
"(TroubleCalls.[WO Reason Code]) Like 'ST*'))"
RealTCs = "(((TroubleCalls.Status) Not Like 'C*' And (TroubleCalls.Status) Not Like 'Follow*') AND " & _
"((TroubleCalls.[WO Reason Code]) Like 'DC*' Or " & _
"(TroubleCalls.[WO Reason Code]) Like 'DD*' Or " & _
"(TroubleCalls.[WO Reason Code]) Like 'IN*' Or " & _
"(TroubleCalls.[WO Reason Code]) Like 'EI*' Or " & _
"(TroubleCalls.[WO Reason Code]) Like 'IM*'))"
FollowUp = "((TroubleCalls.Status) = 'WIP' OR (TroubleCalls.Status) Like 'Follow*')"
Me.FilterOn = False
Select Case Me.cboQue.value
Case "All"
If Me.cboRegion.value = "All" Then
Me.Filter = ""
Else
Me.Filter = "[SPA Info].REGION = '" & Me.cboRegion.value & "'"
End If
Case "Internet/Phone"
If Me.cboRegion.value = "All" Then
Me.Filter = HSD
Else
Me.Filter = HSD & " AND [SPA Info].REGION = '" & Me.cboRegion.value & "'"
End If
Case "Video"
If Me.cboRegion.value = "All" Then
Me.Filter = Video
Else
Me.Filter = Video & " AND [SPA Info].REGION = '" & Me.cboRegion.value & "'"
End If
Case "Follow Up"
If Me.cboRegion.value = "All" Then
Me.Filter = FollowUp
Else
Me.Filter = FollowUp & " AND [SPA Info].REGION = '" & Me.cboRegion.value & "'"
End If
Case "Real TCs"
If Me.cboRegion.value = "All" Then
Me.Filter = RealTCs
Else
Me.Filter = RealTCs & " AND [SPA Info].REGION = '" & Me.cboRegion.value & "'"
End If
Case "Work Order Reason"
If Me.cboRegion.value = "All" Then
Me.Filter = "[TroubleCalls].[WO Reason Code] = '" & Me.cboWOReason.value & "'"
Else
Me.Filter = "[TroubleCalls].[WO Reason Code] = '" & Me.cboWOReason.value & "' AND [SPA Info].REGION = '" & Me.cboRegion.value & "'"
End If
End Select
Me.FilterOn = True
End Sub