I'm not real crazy about opening the report first, then applying the filter. But it is your code
.... I've added the check for the check boxes; be aware I have not tested it!!! Step through it to ensure it is correct.
Code:
Private Sub cmdApplyFilter_Click()
Dim varItem As Variant
Dim strChkbox As String 'OK
Dim strOffice As String
Dim strEmployeetype As String
Dim strFilter As String
' Check that the report is open
If SysCmd(acSysCmdGetObjectState, acReport, "Travel1") <> acObjStateOpen Then
DoCmd.OpenReport "Travel1", acPreview
End If
' Build criteria string from Check boxes
If Me.chkECC Then
strChkbox = "chkECC = TRUE AND "
End If
If Me.chkRCPM Then
strChkbox = strChkbox & "chkRCPM = TRUE AND "
End If
If Me.chkPP Then
strChkbox = strChkbox & "chkPP = TRUE AND "
End If
If Len(Trim(strChkbox)) > 0 Then
'remove the last 5 characters => " AND "
strChkbox = "AND " & Left(strChkbox, Len(strChkbox - 5))
End If
' Build criteria string from lstOffice listbox
For Each varItem In Me.lstOffice.ItemsSelected
strOffice = strOffice & ",'" & Me.lstOffice.ItemData(varItem) _
& "'"
Next varItem
If Len(strOffice) = 0 Then
strOffice = "Like '*'"
Else
strOffice = Right(strOffice, Len(strOffice) - 1)
strOffice = "IN(" & strOffice & ")"
End If
' Build criteria string from fraemployeetype option group
Select Case Me.fraemployeetype.Value
Case 1
strEmployeetype = "='OFFICER'"
Case 2
strEmployeetype = "='SUPERVISOR'"
Case 3
strEmployeetype = "Like '*'"
End Select
' Build filter string
strFilter = "[PORT] " & strOffice & " AND [Employeetype] " & strEmployeetype & strChkbox
'---------------------------------------------------
'for debugging - comment out or delete when the filter string is correct
MsgBox strFilter
'---------------------------------------------------
' Apply the filter and switch it on
With Reports![Travel1]
.Filter = strFilter
.FilterOn = True
End With
End Sub