Private Sub CommandAPplyFilter_Click()
Dim strYears As String
Dim strFilter As String
' Check that the report is open
If SysCmd(acSysCmdGetObjectState, acReport, "Patent_Cost_Forecast") <> acObjStateOpen Then
MsgBox "You must open the report first."
Exit Sub
End If
' Build criteria string for Office field
If Not IsNull(Me.Combo8.Value) Then
strYears = "=" & Me.Combo8.Value & ""
End If
' Combine criteria strings into a WHERE clause for the filter
strFilter = "[Years] " & strYears
' Apply the filter and switch it on
With Reports![Patent_Cost_Forecast]
.Filter = strFilter
.FilterOn = True
End With
End Sub