By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,518 Members | 886 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,518 IT Pros & Developers. It's quick & easy.

Every time that i try to add the quantity to the stock a problem occurred

100+
P: 115
hi i'm working on these tables

database (for shoes)
---------
item_size(Article,size,stock,quantity)
item(Article,stock,price,st_q1,st_q2,st_q3,...,st_ q10, code_supplier)
Order(order_num,order_date,pers_code)
Order_detail(order_num,order_date,code_pers,articl e)
--------------
i did a form to enter the quantity to stock
that form contain order.order_num, order.order_date, order.pers_code, and a subform that contains:
order_detail.order_num, order_detail.order_date, order_detail.code_pers, order_detail.article, order_detail.quantity, order_detail.purchase_price, order_detail.q1, order_detail.q2,..., order_detail.q10, order_detail.SaleOrReturn item.stock, item.st_q1, item.st_q2,..., item.st_q10.
----------------
on the after update of the quantity i wrote this :
Expand|Select|Wrap|Line Numbers
  1. Private Sub quantity_AfterUpdate()
  2. If Me.SaleOrReturn.Value = 1 Then   
  3. 'that means that i'm buying from the supplier
  4. Me.stock.Value = (Nz(Me.stock.Value, 0) - Me.quantity.OldValue)
  5. DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
  6. Me.stock.Value = (Nz(Me.stock.Value, 0) + Me.quantity.Value)
  7. Else ' Here i'm returning articles to the supplier
  8. Me.stock.Value = (Nz(Me.stock.Value, 0) + Me.quantity.OldValue)
  9. DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
  10. Me.stock.Value = (Nz(Me.stock.Value, 0) - Me.quantity.Value)
  11. End If
  12. End Sub
----------------------
When the form load i can see the value of the stock for example 49 for the article1, but when i insert the value of the quantity for example (quantity=1) the value of the stock change also to 1 !! (But the true value should be 50 = 49+1)
and when i delete the record the field stock in the table item is updated to 0 !!
Any one can help please!! ??

--------------
I had also tried this code:
Expand|Select|Wrap|Line Numbers
  1. Me.stock.Value = (Me.stock.Value - Me.quantity.OldValue)
  2. DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
  3. Me.stock.Value = (Me.stock.Value + Me.quantity.Value)
  4. Else
  5. Me.stock.Value = (Me.stock.Value + Me.quantity.OldValue)
  6. DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
  7. Me.stock.Value = (Me.stock.Value - Me.quantity.Value)
  8.  
On load the stock is 49 after i add a 1 to the quantity, the stock field became null!!
-----------------
I now it's a long question but hope someone will help . Thanks! :)
Aug 4 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.