Grrr.... this has been a pain for a week now. Hopefully someone will be able to help. I want to have a query update table values based on the min values of a different query. Here's what I have (well, just the important stuff):
Table: Exhibitors
Field: mrkt_pts
Table: Livestock
Field: Exhibitor_ID
Field: Placing
Each exhibitor can have multiple livestock, thus they can have multiple placings. So I created a query to show only their highest placing animal:
Query: qry_supcomp_mrkt_pts
This outputs (Example):
Exhibitor ID | Name | Tag No. | Min Placing
108 | John Doe | 5001 | 1
And here's where I hang up.... I want to create a query that updates the [Exhibitors]![mrkt_pts] according to the Min Placing. For example...
If Min Placing = 1, then update [Exhibitors]![mrkt_pts] = 15
If Min Placing = 2, then update [Exhibitors]![mrkt_pts] = 14
If Min Placing = 3, then update [Exhibitors]![mrkt_pts] = 13
If Min Placing = 4, then update [Exhibitors]![mrkt_pts] = 12
etc..
If Min Placing = or > 15, then update [Exhibitors]![mrkt_pts] = 1
I tried several different variations of the following query [update_qry_supcomp_mrkt_pts] to just update mrkt_pts to 15 where Min Placing = 1:
But I just get the "Operation must use an updateable query" error.
ANY help would be GREATLY appreciated!
Thanks,
Audrey
Table: Exhibitors
Field: mrkt_pts
Table: Livestock
Field: Exhibitor_ID
Field: Placing
Each exhibitor can have multiple livestock, thus they can have multiple placings. So I created a query to show only their highest placing animal:
Query: qry_supcomp_mrkt_pts
Code:
SELECT DISTINCTROW exhibitors.ID, exhibitors.Name, First(livestock.ExhibitorID) AS [First Of ExhibitorID], First(livestock.[Tag No]) AS [First Of Tag No], Min(livestock.Placing) AS [Min Of Placing], First(livestock.market_animal) AS [First Of market_animal]
FROM exhibitors LEFT JOIN livestock ON exhibitors.ID = livestock.ExhibitorID
GROUP BY exhibitors.ID, exhibitors.Name
HAVING (((First(livestock.market_animal))=-1));
This outputs (Example):
Exhibitor ID | Name | Tag No. | Min Placing
108 | John Doe | 5001 | 1
And here's where I hang up.... I want to create a query that updates the [Exhibitors]![mrkt_pts] according to the Min Placing. For example...
If Min Placing = 1, then update [Exhibitors]![mrkt_pts] = 15
If Min Placing = 2, then update [Exhibitors]![mrkt_pts] = 14
If Min Placing = 3, then update [Exhibitors]![mrkt_pts] = 13
If Min Placing = 4, then update [Exhibitors]![mrkt_pts] = 12
etc..
If Min Placing = or > 15, then update [Exhibitors]![mrkt_pts] = 1
I tried several different variations of the following query [update_qry_supcomp_mrkt_pts] to just update mrkt_pts to 15 where Min Placing = 1:
Code:
UPDATE qry_supcomp_mrkt_pts INNER JOIN exhibitors ON qry_supcomp_mrkt_pts.ID = exhibitors.ID SET exhibitors.MarketPoints = 15
WHERE (((qry_supcomp_mrkt_pts.[Min Of Placing])=1));
But I just get the "Operation must use an updateable query" error.
ANY help would be GREATLY appreciated!
Thanks,
Audrey