p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access VBA (http://p2p.wrox.com/forumdisplay.php?f=80)
-   -   Update Table fields (http://p2p.wrox.com/showthread.php?t=22137)

karajian December 5th, 2004 01:42 PM

Update Table fields
 
Please Help !
I made a access db with following tables:
Producs
Orders
OrderDetails
Customers
I can't update the stock field of products table when input a new order from orders form. For Example
I have a stock of 15 pcs for a product.A customer orders 5 pcs of this product.I am searching a way so when I input this order (in orders form) the stock field of table Products updates to 10 pcs(15-5)
I tried several ways to solve this problem (Vba ,Sql) but nothing.
I appreciate if you help me
Thank you in advance
P.S. If this help I can tell you more details or send a demo of my db


Ray Pinnegar December 6th, 2004 05:30 AM

Suspect that the record you are trying to update is a result of a join of tables where there Primary and Foreign keys are not truly unique and thus can't update.

Suggest that you run a UPDATE query using the unique index of the record in the OrderDetails table only.

Cheers Ray

bfurman December 7th, 2004 03:48 PM

update table Products from trigger for update on OrderDetails table:
 minus stock Products where Orderdetail.ProductID = inserted.ProductID

and plus from trigger for delete.




All times are GMT -4. The time now is 08:31 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.