Hi
Thanks for your input but I can’t get it to work. Do I need to put an on_click or an After_update event in the first box to run the second query (qrysum) and populate the second list box.
Here is my setup below.
I have a form called frmsearchNew.
I have a combo box called pickpart to give a list of distinct part numbers.
(This list box is based on a simple select distinct query).
User should be able to select a part no in the first combo box and the chosen part will be used in a second query whose results will be displayed in a list box in the same form.
The second query is called qrySum
I have put in the code you suggested [forms]![frmsearchNew]![pickpart] in the field required – see SQL below - but I get nothing returned from the query no matter what part I choose. When I try the query with out this line
HAVING (((tblstock.[MaterialPart#])=[forms]![frmsearchNew]![pickpart])) I get all the data.
Example with line
SELECT tblstock.[MaterialPart#], tblstock.[Lot#], tblstock.Location, Sum(tblstock.Qty) AS SumOfQty
FROM tblstock
GROUP BY tblstock.[MaterialPart#], tblstock.[Lot#], tblstock.Location
HAVING (((tblstock.[MaterialPart#])=[forms]![frmsearchNew]![pickpart]))
ORDER BY tblstock.[MaterialPart#] DESC;
Query minus line which gives all data
SELECT tblstock.[MaterialPart#], tblstock.[Lot#], tblstock.Location, Sum(tblstock.Qty) AS SumOfQty
FROM tblstock
GROUP BY tblstock.[MaterialPart#], tblstock.[Lot#], tblstock.Location
ORDER BY tblstock.[MaterialPart#] DESC;
Any ideas on what I'm doing wrong
Thanks