I looked at your code.... you must not have these two lines at the top of every code page:
Code:
Option Compare Database
Option Explicit
I have never seen where a filter was applied to a report AFTER it was opened.
As Minty said, I would open the report with the WHERE clause of the OPENREPORT command.
In the routine "btnRemoveFilter_Click", "varItem" has not been declared and causes an error.
As far as the btnApplyFilter_Click routine, you have undefined names in the code:
Code:
Private Sub btnApplyFilter_Click()
Dim varItem As Variant
Dim strPhase As String
Dim strDeveloper As String
Dim strFilter As String
' Check that the report is open
If SysCmd(acSysCmdGetObjectState, acReport, "rptTaxReturnReport") <> acObjStateOpen Then
MsgBox "You must open the report first."
Exit Sub
End If
' Build criteria string from listPhase listbox
For Each varItem In Me.listPhase.ItemsSelected
strPhase = strPhase & "," & Me.strPhase.ItemData(varItem) '<< NO such control
Next varItem
If Len(strPhase) = 0 Then
strPhase = "Like '*'"
Else
strPhase = Right(strPhase, Len(strPhase) - 1)
strPhase = "IN(" & strPhase & ")"
End If
' Build criteria string from listDeveloper listbox
For Each varItem In Me.listDeveloper.ItemsSelected
strDeveloper = strDeveloper & "," & Me.strDeveloper.ItemData(varItem) '<< NO such control
Next varItem
If Len(strDeveloper) = 0 Then
strDeveloper = "Like '*'"
Else
strDeveloper = Right(strDeveloper, Len(strDeveloper) - 1)
strDeveloper = "IN(" & strDeveloper & ")"
End If
' Build filter string
strFilter = "[Phase] " & strPhase & " AND [Developer] " & strDeveloper
' Apply filter to report
With Reports![rptTaxReturnReport]
.Filter = strFilter
.FilterOn = True
End With
End Sub