Can someone tell me why this function is asking for a parameter?
Code:
Option Compare Database
Option Explicit
Function MultipleValueCriteria(pform As Form, _
pcontrol As ListBox, pfield As String)
'Launch rptSummaryReport using
'OR criteria built on field
'passed by pfield; report must be
'passed via the forms Tag property.
Dim var As Variant
Dim strCriteria As String
If pcontrol.ItemsSelected.Count = 0 Then
MsgBox "Please select at least 1 Department!", _
vbOKOnly, "Error"
Exit Function
'Build SQL statement using selected Departments
Else
'Criteria expression uses literal string
'values. If using numeric or date values,
'update delimeter component.
For Each var In pcontrol.ItemsSelected
strCriteria = strCriteria & _
pfield & " = '" & _
pcontrol.ItemData(var) _
& "' Or "
Next var
End If
strCriteria = Left(strCriteria, _
Len(strCriteria) - 4)
Debug.Print strCriteria
'Open filtered report and close form.
DoCmd.OpenReport pform.Tag, _
acViewPreview, , strCriteria
DoCmd.Close acForm, pform.Name
Set pcontrol = Nothing
Set pform = Nothing
End Function