The where clause should look like: where company = A or company = B or company = C ......, depending on how many item selected by user.
So then why didn't you do that in your code???
Code:
Dim strWhere as string
strWhere = " WHERE 0=1 " ' sneaky trick
Dim i as integer
For i = 0 To ListTest.ListCount - 1
If ListTest.Selected(litem) = True Then
strWhere = strWhere & " OR company = '" ListTest.ItemData(i) & "'"
End If
Next
But you could also do it using IN( ) which would be more efficient.
Code:
Dim strWhere as string
strWhere = " WHERE company IN ('*?*'"
Dim i as integer
For i = 0 To ListTest.ListCount - 1
If ListTest.Selected(litem) = True Then
strWhere = strWhere & ",'" ListTest.ItemData(i) & "'"
End If
Next
strWhere = strWhere & ") "
You see it?
In the first case you end up with
WHERE 0=1 OR company='A' OR company='X'
in the second case you end up with
WHERE company IN ('*?*','A','X')
(I'm assuming the '*?*' is an impossible company, so it doesn't affect the results of the IN ( ), of course.)
The big reason to use IN( ) is so that you don't have to worry about complex parentheses if there will be other conditions in your WHERE.