Access 2003 on WinXP
Brief database layout:
MM is a master table linked to MD via a field GID. MD is a detail table with one or more records per MM record.
I'm generating an SQL string on-the-fly to be the source of a listbox control. The SQL statement uses aggregate functions so I can get the last job listed on a MM (master) record. After constructing the SQL I set the Listbox.Rowsource to the SQL string. Here is the string:
At the bottom of my form with the Listbox control I have a text box listing this sql statement for debugging purposes. So the form does not actually throw an error, but I get no records showing in the listbox.
Does anyone see anything wrong with the SQL statement?
Brief database layout:
MM is a master table linked to MD via a field GID. MD is a detail table with one or more records per MM record.
I'm generating an SQL string on-the-fly to be the source of a listbox control. The SQL statement uses aggregate functions so I can get the last job listed on a MM (master) record. After constructing the SQL I set the Listbox.Rowsource to the SQL string. Here is the string:
Code:
SELECT MM.GID, MM.NameOfProduce1, MM.UPCPLU, MM.Foodcat, Max(MD.Jobnum) AS LastJob
FROM MM LEFT JOIN MD ON MM.GID = MD.GID
GROUP BY MM.GID, MM.NameOfProduce1, MM.UPCPLU, MM.FoodCat, LastJob HAVING (
(len(Jobnum)>0) and (MM.FoodCat='000 WetVeg') and (nz(MM.C3x5)>0)
) ORDER BY MM.NameOfProduce1;
Does anyone see anything wrong with the SQL statement?
Last edited: