This is the code
Private Sub Command2_Click()
Dim strCountry As String
Dim strFilter As String
Dim strYears as Long
' 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 Country field
If IsNull(Me.ComboCountry.Value) Then
strCountry = "Like '*'"
Else
strCountry = "='" & Me.ComboCountry.Value & "'"
End If
' Build criteria string for years field
If IsNull(Me.ComboYears.Value) Then
strYears = "Like '*'"
Else
strYears = "='" & Me.ComboYears.Value & "'"
End If
' Combine criteria strings into a WHERE clause for the filter
strFilter = "[Country] " & strCountry & "AND [Years]" & strYears
' Apply the filter and switch it on
With Reports![Patent_Cost_Forecast]
.Filter = strFilter
.FilterOn = True
End With
End Sub
Private Sub Command2_Click()
Dim strCountry As String
Dim strFilter As String
Dim strYears as Long
' 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 Country field
If IsNull(Me.ComboCountry.Value) Then
strCountry = "Like '*'"
Else
strCountry = "='" & Me.ComboCountry.Value & "'"
End If
' Build criteria string for years field
If IsNull(Me.ComboYears.Value) Then
strYears = "Like '*'"
Else
strYears = "='" & Me.ComboYears.Value & "'"
End If
' Combine criteria strings into a WHERE clause for the filter
strFilter = "[Country] " & strCountry & "AND [Years]" & strYears
' Apply the filter and switch it on
With Reports![Patent_Cost_Forecast]
.Filter = strFilter
.FilterOn = True
End With
End Sub