View Full Version : update query, need to total up several items seperatly


med
01-25-2002, 02:49 AM
hey, i need a step be step guide to how to do this as im really lost

I have a query in which i have an ID number and a quantity relating to a part table. I need to make some sort of query to add up all the quantities of one ID, then subtract it from the total quantity, then do this again with the other ID's
My query looks like this, it is an order query, showing what has been purchased

ID Quantity
1 10
1 30
2 50
2 20
2 25

I then have a table somewhere else with the IDs and the total quantities in stock and their IDs
eg
1 500
2 400
etc

What i need to do is add up all quatity values for each ID, so i add up all the ID 1 quatities and get a total, and then subract this total from the overall total in my other table

appreciate any help

Harry
01-25-2002, 03:20 AM
The query that shows the ID and quantity puchased needs to be a Totals query. To do this, go into design view, then on the menu bar select View / Totals. You will now see an extra row in the table called Total: Set the ID field total to Group By and the Quantity field total to sum. Now you have the total ordered by ID.

Next, create a query with your main table and the above query. Link the ID fields together. Select ID from the main table, then in the next field have Remain: [TableName]![Quantity]-[qryName]![TotalQuantity]

HTH

med
01-25-2002, 03:59 AM
thanks for your help, i follow the first part and i get it totaling up the relevent IDs, but im stuck on getting the second query working, would you ming explaining it more please

med
01-25-2002, 04:09 AM
I got it working!
sorry, i just wansnt following you right at the start, but im all sorted now

thanks alot for your help!

med
01-25-2002, 04:11 AM
Now if i wanted to get that remain value to replace the old stock amount what would be the best way of going about it

would i simple create a copy macro, or is their a better way?