Update Query Help Please

G

Guest

I have run a query that totals all charges for a particular orderid and the
results are in a field called [sum] within that query.

I want to update a field called [OrderTotal] in a table called History with
the result of the field [sum] based on OrderID.

I'm very poor at code so I tried putting the query with the sum value in it
and the table I want to update into an update query but I am having problems
figuring that out also.

Any Help would be appreciated.
 
C

Cindy

Code solution would be more elegant - but since you posted this in the
query section and it sounds like you'd just as soon have it using
queries, you'll need to create a temporary table first with your
sums. An update query using another query that sums your data won't
work because the "act of summing" makes the query "non-updateable".

So - step 1: Create a totals query using the OrderId and the
Ordertotal fields. Do a group by on the OrderID and a sum of the
fields that has the individual order dollar amountsl. Change the
query type to a Make Table query. Run it, giving the new table a name
- something like "tempTotals".

Step 2 - create an update query joining your History table with the
tempTotals table on the Order ID. Under the OrderTotal field set the
"update to" portion equal to the name of the field that stores the
total in your tempTotal.

Step 3 - run it with exclamation point.

Cindy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top