cyclops1eye
Programmer
HI! I have a fun one here. I am trying to populate a ListBox in Access using two tables... and what I have for fields are these:
ID Product_Number Serial_Number Checked
-- ------------------- ----------------- ----------
Now, the "Checked" field doesn't go into the ListBox, it's used as a field for criteria to get into the ListBox.
Assuming that both tables are set up equally, what I need to see in the ListBox is a distinct entry for each product / serial number combination FROM Table1 WHERE Checked=True... The trick is this: Each line in the listbox needs to be distinct, I also need to have the ID in the ListBox from Table1 only -- (although I don't want it visible), AND I need to have another field in the ListBox that COUNTs all the times that each Serial_Number that shows up in the ListBox exists in Table1 and Table2 regardless of whether or not Checked=True.
What I have is this:
"SELECT ID, A1.Product_Number AS PN, A1.Serial_Number AS SN, COUNT(A1.Serial_Number) + COUNT(A2.Serial_Number) AS COUNT
FROM Table1 AS A1, Table2 AS A2
WHERE A1.Checked=True
GROUP BY A1.Product_Number, A1.Serial_Number"
The Problem with this is that it yields only a count of 1, because even though the Serial_Number may appear several times within the database, it is only going to be checked once. What I need to show up in the COUNT column is not the count of the ID / Product_Number / Serial_Number combination, but rather a count of all of the Serial_Number's that appear within the database at all.
Does that make sense?
PLZ HELP!
--
Cyclops_One_Eye
ID Product_Number Serial_Number Checked
-- ------------------- ----------------- ----------
Now, the "Checked" field doesn't go into the ListBox, it's used as a field for criteria to get into the ListBox.
Assuming that both tables are set up equally, what I need to see in the ListBox is a distinct entry for each product / serial number combination FROM Table1 WHERE Checked=True... The trick is this: Each line in the listbox needs to be distinct, I also need to have the ID in the ListBox from Table1 only -- (although I don't want it visible), AND I need to have another field in the ListBox that COUNTs all the times that each Serial_Number that shows up in the ListBox exists in Table1 and Table2 regardless of whether or not Checked=True.
What I have is this:
"SELECT ID, A1.Product_Number AS PN, A1.Serial_Number AS SN, COUNT(A1.Serial_Number) + COUNT(A2.Serial_Number) AS COUNT
FROM Table1 AS A1, Table2 AS A2
WHERE A1.Checked=True
GROUP BY A1.Product_Number, A1.Serial_Number"
The Problem with this is that it yields only a count of 1, because even though the Serial_Number may appear several times within the database, it is only going to be checked once. What I need to show up in the COUNT column is not the count of the ID / Product_Number / Serial_Number combination, but rather a count of all of the Serial_Number's that appear within the database at all.
Does that make sense?
PLZ HELP!
--
Cyclops_One_Eye