Hello, I'm trying to retrieve the latest price date for a particular material ID. My db has 3 tables.
tblMaterialDesc
DescriptionID(PK)
MaterialDesc
tblSellerName
tblSellerNameID
SellerName
tblPrice
PriceDate
PriceEach
MarkUp
SellingPrice
tblSellerNameID
tblMaterialID
I'm using combo boxes to place the material ID and Seller ID into table tblPrice. Works fine. Now I want to place the latest prices into a listbox but I'm having trouble with the query to get the prices.
I'm trying to make a query that will return the latest date for a particular material and the price each.
Here's my SQL so far. The 12 parameter is just for testing.
When I add the price each I get all the records. I tried using this query as a subquery for a new query and placing links between this query and the tblPrice but I still get all the records.
How can I pull out the latest date and price for a particular material ID? I suppose tblPrice could be called a transition table. It's just the way I set it, although I can change it if you think it's set up wrong.
Thanks Jim
tblMaterialDesc
DescriptionID(PK)
MaterialDesc
tblSellerName
tblSellerNameID
SellerName
tblPrice
PriceDate
PriceEach
MarkUp
SellingPrice
tblSellerNameID
tblMaterialID
I'm using combo boxes to place the material ID and Seller ID into table tblPrice. Works fine. Now I want to place the latest prices into a listbox but I'm having trouble with the query to get the prices.
I'm trying to make a query that will return the latest date for a particular material and the price each.
Here's my SQL so far. The 12 parameter is just for testing.
Code:
SELECT Max(tblPrice.PriceDate) AS MaxOfPriceDate, tblPrice.tblSellerNameID, tblPrice.tblMaterialID
FROM tblPrice
GROUP BY tblPrice.tblSellerNameID, tblPrice.tblMaterialID
HAVING (((tblPrice.tblMaterialID)=12));
How can I pull out the latest date and price for a particular material ID? I suppose tblPrice could be called a transition table. It's just the way I set it, although I can change it if you think it's set up wrong.
Thanks Jim