I am trying to create a report that allows the user to select multiple contractors. I found this code and it works except for the last line. I know this is pretty simple but I don't know how to fix it. The code in RED is what is not working.
Code:
Private Sub cmdPerfIssuesContractorRpt_Click()
On Error GoTo Err_cmdPerfIssuesContractorRpt_Click
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.cboContractorSelection.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 employee"
Exit Sub
End If
'add selected values to string
Set ctl = Me.cboContractorSelection
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & ctl.ItemData(varItem) & ","
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
'open the report, restricted to the selected items
DoCmd.OpenReport "rptPerfIssuesbyContractor", acPreview, , "Contractor IN(" & strWhere & ")"
Exit_cmdPerfIssuesContractorRpt_Click:
Exit Sub
Err_cmdPerfIssuesContractorRpt_Click:
MsgBox Err.Description
Resume Exit_cmdPerfIssuesContractorRpt_Click
End Sub