Update query to update new qty and cost

K

KevinK

I have a query that is intended to update the quantity and total cost for
items purchased. This query is run after a new purchase order is entered.
It’s updated off the form so the current information is the only qty and cost
that are added to only the items purchased. This update query gets the
information from the PurchOrderDetailtbl. Here the criteria for that query.

The Itemtbl is linked to the PurchOrderDetailtbl by ItemID

The field in the Itemtbl, TotalQty has update to:
NZ([TotalQty],0)+[PurchOrderDetailtbl]![PQty]

The field in the Itemtbl, TotalCost has update to:
NZ([TotalCost],0)+[PurchOrderDetailtbl]![Inventory]

The field in the PurchOrderDetailtbl, PurchaseOrder has the criteria:
[Forms]![PurchOrderAddfrm]![PurchOrder]

I have a button on the PurchOrderAddfrm that I push after all the new or
existing items have been added to the PurchOrderDetailtbl.
After I push the button I get the standard message for update queries, but
the next message says it will update 0 records.
 
A

Allen Browne

Kevin, *don't* store the total cost in your table.
Please, don't! Whatever you do, don't!

The one thing that computers are actually really good at is maths. Get it to
calculate the totals for you. You will save yourself so much grief, trying
to ensure that you keep your stored totals right, regardless of how the line
items are added, deleted, or edited.

The Northwind sample database has an example of how the extended price can
be calculated for the line item, and the total displayed for the whole
order. Check out the Orders form.
 

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