J
jamesarnall
Guest
Hi all: I am trying to filter a query based on user input from a ListBox. I loop thru the ListBox and build a comma-delimited list of IDs. It takes one parameter, but if there are 2 or more items in the list, it returns nothing. It's not the query, because if I hard code the same comma-delimited list into the SQL query ("...WHERE CategoryID IN (1,2,3)") it works fine.
This is the query:
SELECT tbl_Subsidiary.SubsidiaryName AS Brand, Sum(tbl_Placeview.Duration) AS SumOfDuration
FROM tbl_Subsidiary INNER JOIN tbl_Placeview ON tbl_Subsidiary.SubsidiaryID = tbl_Placeview.SubsidiaryID
WHERE (((tbl_Placeview.AirTime) Between [Forms]![frmTopBrandsByCategory]![txt_DateFrom] And [Forms]![frmTopBrandsByCategory]![txt_DateTo]) AND ((tbl_Placeview.CategoryID) In ([Forms]![frmTopBrandsByCategory]![txt_CategoryList])))
GROUP BY tbl_Subsidiary.SubsidiaryName
ORDER BY Sum(tbl_Placeview.Duration) DESC;
You can see I'm getting the list of "CategoryID" from a text field; after getting my comma-delimited list from the list box, I assign it to a hidden text field. In debug I can see that the list of IDs is built correctly.
Any ideas? I'm pulling out my hair over this!
Thanks in advance,
james
This is the query:
SELECT tbl_Subsidiary.SubsidiaryName AS Brand, Sum(tbl_Placeview.Duration) AS SumOfDuration
FROM tbl_Subsidiary INNER JOIN tbl_Placeview ON tbl_Subsidiary.SubsidiaryID = tbl_Placeview.SubsidiaryID
WHERE (((tbl_Placeview.AirTime) Between [Forms]![frmTopBrandsByCategory]![txt_DateFrom] And [Forms]![frmTopBrandsByCategory]![txt_DateTo]) AND ((tbl_Placeview.CategoryID) In ([Forms]![frmTopBrandsByCategory]![txt_CategoryList])))
GROUP BY tbl_Subsidiary.SubsidiaryName
ORDER BY Sum(tbl_Placeview.Duration) DESC;
You can see I'm getting the list of "CategoryID" from a text field; after getting my comma-delimited list from the list box, I assign it to a hidden text field. In debug I can see that the list of IDs is built correctly.
Any ideas? I'm pulling out my hair over this!
Thanks in advance,
james