Can you guys help me. I'm having problems trying to build a criteria for my srtYear field. Do you guys have any solutions?
Private Sub cmdApplyFilter_Click()
Dim strMonth As String
Dim strYear As String
Dim strFilter As String
' Check that the report is open
If SysCmd(acSysCmdGetObjectState, acReport, "rptTracking") <> acObjStateOpen Then
MsgBox "You must open the report first."
Exit Sub
End If
' Build criteria string for Month field
If IsNull(Me.cboMonth.Value) Then
strMonth = "Like '*'"
Else
strMonth = "='" & Me.cboMonth.Value & "'"
End If
' Build criteria string for Year field
If IsNull(Me.cboYear.Value) Then
strYear = "Like '*'"
Else
strYear = "='" & Me.cboYear.Value & "'"
End If
' Combine criteria strings into a WHERE clause for the filter
strFilter = "[Month] " & strMonth & " AND [Year] " & strYear
' Apply the filter and switch it on
With Reports![rptTracking]
.Filter = strFilter
.FilterOn = True
End With
End Sub
Private Sub cmdRemoveFilter_Click()
On Error Resume Next
' Switch the filter off
Reports![rptTracking].FilterOn = False
End Sub