what can i add to the code below that will also filter the report by 3 unbound check boxes. My employees have 3 required items to obtain before they are certified and i want to be able to filter my report based on any 1, 2 or all 3 and mix and match the requirements. The code below works great for Employee type as an option group and Office location as a multi select list box. I have done internet search every which way and scoured other example databases and i can't find the coding that successfully adds in 3 unbound check boxes. The 3 values in my table the report is based on is also Yes/No values.
Private Sub cmdApplyFilter_Click()
Dim varItem As Variant
Dim strChkbox As String <do i need 3 of these? like chkbox1, chkbox2 ect?
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
' 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
' Apply the filter and switch it on
With Reports![Travel1]
.Filter = strFilter
.FilterOn = True
End With
End Sub
Private Sub cmdApplyFilter_Click()
Dim varItem As Variant
Dim strChkbox As String <do i need 3 of these? like chkbox1, chkbox2 ect?
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
' 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
' Apply the filter and switch it on
With Reports![Travel1]
.Filter = strFilter
.FilterOn = True
End With
End Sub