Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

code to filter report based on check boxes

$
0
0
Need help I am using the Onclick event of a button to open an unfiltered report and filter based on the criteria selected on the form with the button. I have successfully added an Option group and a MultiSelect box and it works perfectly. The record set i am using has 3 values set as check boxes. I want to incorporate this into the Filter but i am unsure how to accomplish this. I have researched anything related i can think of to point me in the right direction.

chkECC
chkRCMP
chkPASSPORT

As each one is selected it will filter to employees that have completed more of the requirements

Here is the code i am using so far for the multiselect and Option group

Private Sub cmdApplyFilter_Click()
Dim varItem As Variant
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 chkbox


' 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

Viewing all articles
Browse latest Browse all 13329

Trending Articles