I am trying to set the criteria in a query to only show the items selected in a list box. Here is my problem.
When the query tries to read, the value of the function returning the criteria is:
"'0101AA' or '0101AB' or '0101AC' or '0102AA' or '0102AB'"
ie. the criteria I want, however it is surrounded by quotes.
basically, I just want my function to return:
'0101AA' or '0101AB' or '0101AC' or '0102AA' or '0102AB'
Help! (I know I've done this before, but I can't remember which project it was)
Joe
Here are the coding particulars if you are interested...
In the query, I have:
ReportCLINS()
as the criteria of one of the columns.
I get ReportCLINS() from a function that reads my List Box ("List0"):
When the query tries to read, the value of the function returning the criteria is:
"'0101AA' or '0101AB' or '0101AC' or '0102AA' or '0102AB'"
ie. the criteria I want, however it is surrounded by quotes.
basically, I just want my function to return:
'0101AA' or '0101AB' or '0101AC' or '0102AA' or '0102AB'
Help! (I know I've done this before, but I can't remember which project it was)
Joe
Here are the coding particulars if you are interested...
In the query, I have:
ReportCLINS()
as the criteria of one of the columns.
I get ReportCLINS() from a function that reads my List Box ("List0"):
Code:
Function ReportCLINS()
Dim ctlSource As Control
Dim strItemsTO As String
Dim intCurrentRow As Integer
Dim FilterItems As Variant
FilterItems = 0
Set ctlSource = Forms!TotalOrder!List0
'Set ctlDest = frm!lstDestination
For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
If FilterItems = 0 Then
strItemsTO = "='" & ctlSource.Column(0, _
intCurrentRow) & "' or '"
Else
strItemsTO = strItemsTO & ctlSource.Column(0, _
intCurrentRow) & "' or '"
End If
FilterItems = FilterItems + 1
End If
Next intCurrentRow
strItemsTO = Trim(Left(strItemsTO, Len(strItemsTO) - 5))
Set ctlSource = Nothing
Set ctlDest = Nothing
ReportCLINS = strItemsTO
End Function