I have the following sub I am trying to use to build a where statement to open a report. First I loop through list boxes I have tagged with "Go". If the listbox, ctl, is visible then It means there is a selection. I then do a select case to assign it a string that I pass to my function to build the In statement. I keep getting an error when I try to pass ctl.name to my function. help please
For Each ctl In Me.Controls
If ctl.Tag = "Go" Then
If ctl.NAME.Visible Then
Select Case ctl.NAME
strField = "Customer"
strField = "Carrier"
If strField <> "" Then
strBuildRptWhere = BuildStringLists(ctlPass, strField)
There is the function to build the In statement
Function BuildStringLists(ByVal ctlList As Control, ByVal strField As String) As String
Dim i As Integer
Dim strIn As String
'Build the IN string by looping through the listbox
For i = 0 To ctlList.ListCount - 1
If ctlList.Selected(i) Then
strIn = strIn & "'" & ctlList.Column(0, i) & "',"
If strIn <> "" Then
BuildStringLists = " AND " & strField & " in (" & Left(strIn, Len(strIn) - 1) & ")"