Hello,
I have a multi select listbox that is used to add id's to a query. Specifically:
...in the where clause at the end, the items selected in the listbox are added to a string, a textbox is set to the value of that string (for display purposes) and then this text box's string/value is used in the where in list...
But it doesn't work well for some reason. When a single record is selected, effectively giving a single value in the "where in" clause, this works just fine.
...and further, if I hard code multiple values into the query:
...that works fine too.
But for some reason, when building the additional n'th records to the string it fails to return any records at all.
The mdb is running against SQL Server as the backend. The id's are integers, and teh building code is:
Boy, I am stumped!
Thoughts?
I have a multi select listbox that is used to add id's to a query. Specifically:
Code:
SELECT dbo_tblTaggedItems.TaggedItemID, dbo_tblItems.ItemDescription, ' ' AS [space], dbo_tblTags.TagDescription
FROM (dbo_tblTaggedItems INNER JOIN dbo_tblItems ON dbo_tblTaggedItems.ItemID = dbo_tblItems.ItemID) INNER JOIN dbo_tblTags ON dbo_tblTaggedItems.TagID = dbo_tblTags.TagID
WHERE dbo_tblTags.TagID in ( [forms].[frmTagItems].[txtstrWhere].value );
But it doesn't work well for some reason. When a single record is selected, effectively giving a single value in the "where in" clause, this works just fine.
...and further, if I hard code multiple values into the query:
Code:
SELECT dbo_tblTaggedItems.TaggedItemID, dbo_tblItems.ItemDescription, ' ' AS [space], dbo_tblTags.TagDescription
FROM (dbo_tblTaggedItems INNER JOIN dbo_tblItems ON dbo_tblTaggedItems.ItemID = dbo_tblItems.ItemID) INNER JOIN dbo_tblTags ON dbo_tblTaggedItems.TagID = dbo_tblTags.TagID
WHERE dbo_tblTags.TagID in ( 6,7,8);
But for some reason, when building the additional n'th records to the string it fails to return any records at all.
The mdb is running against SQL Server as the backend. The id's are integers, and teh building code is:
Code:
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'add selected values to string
Set ctl = Me.lstTags
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & ctl.ItemData(varItem) & ","
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
txtstrWhere = strWhere
Thoughts?