Hi,
Can someone who understands SQL syntax check the following for me?
TxtSearch2 is a textbox on a Form, Form1 which also contains a listbox, list0.
This is a test page to get the SQL statement working directly in the code window. I'm doing this because since moving a listbox into a Tab Control, the criteria for the underlying query no longer works - or rather, I don't know the syntax for addressing a listbox in a tab from the query design window.
I'm pretty sure the problem is with the third SQL line (WHERE clause), since the listbox should just show stock items, but it's showing them all - I guess it's an issue with the bracketing?
Thanks,
S
Can someone who understands SQL syntax check the following for me?
TxtSearch2 is a textbox on a Form, Form1 which also contains a listbox, list0.
This is a test page to get the SQL statement working directly in the code window. I'm doing this because since moving a listbox into a Tab Control, the criteria for the underlying query no longer works - or rather, I don't know the syntax for addressing a listbox in a tab from the query design window.
I'm pretty sure the problem is with the third SQL line (WHERE clause), since the listbox should just show stock items, but it's showing them all - I guess it's an issue with the bracketing?
Code:
Dim strsql As String strsql = "SELECT Products.ProductID, [categories.categoryname] & ' ' & [Widths] & [Series] & [Rating] & [Diameters] & ' ' & [Manufacturer] & ' ' & [Notes] AS Product,Products.Trade, Products.StockLevel " strsql = strsql & "FROM Categories INNER JOIN Products ON Categories.CategoryID = Products.categoryid " strsql = strsql & "WHERE (([categories.categoryname] & [Widths] & [Series] & [Rating] & [Diameters] & [Manufacturer] & [Notes]) Like '*') & [Forms]![form1]![txtSearch2] & '*') AND ((Products.StockLevel)>0) " strsql = strsql & "ORDER BY Products.CategoryID, Products.Series DESC , Products.Diameters, Products.Widths, Products.Rating;"
S
Comment