Question : Update table with SUM from another table.

So here's what I've got:

I have a table full of the number of parts ordered (Part) and another table with the items that have been ordered (OrderLine):

Part
PartNum (INTEGER)
Allocation (INTEGER)

OrderLine
OrderNum (INTEGER)
PartNum (INTEGER)
NumOrdered (INTEGER)

Now, I need to get a sum of all the items that are in OrderLine that have "PartNum" and update the Allocation field of "Part" to this value in a single SQL statement.

I've been at this for about 5 hours now and can't seem to figure it out.  Initially, I thought this should work:

1:
2:
3:
4:
5:
6:
7:
UPDATE Part
   SET Allocation = (SELECT SUM(Temp.NumOrdered)
                    FROM OrderLine AS Temp
                    WHERE Temp.PartNum  = Part.PartNum)
   WHERE Part.PartNum = 'KV29'
;


But this kicks back telling me that it's not an "updatable query".

Any help?


Answer : Update table with SUM from another table.

This site explains the problem and provides some alternate solutions.
http://www.fmsinc.com/microsoftaccess/query/non-updateable/index.html#Example 2: Updating a Field with a Summary Query
Random Solutions  
 
programming4us programming4us