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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hannoudw
    New Member
    • Aug 2010
    • 115

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

    hi i'm working on these tables

    database (for shoes)
    ---------
    item_size(Artic le,size,stock,q uantity)
    item(Article,st ock,price,st_q1 ,st_q2,st_q3,.. .,st_q10, code_supplier)
    Order(order_num ,order_date,per s_code)
    Order_detail(or der_num,order_d ate,code_pers,a rticle)
    --------------
    i did a form to enter the quantity to stock
    that form contain order.order_num , order.order_dat e, order.pers_code , and a subform that contains:
    order_detail.or der_num, order_detail.or der_date, order_detail.co de_pers, order_detail.ar ticle, order_detail.qu antity, order_detail.pu rchase_price, order_detail.q1 , order_detail.q2 ,..., order_detail.q1 0, order_detail.Sa leOrReturn item.stock, item.st_q1, item.st_q2,..., item.st_q10.
    ----------------
    on the after update of the quantity i wrote this :
    Code:
    Private Sub quantity_AfterUpdate()
    If Me.SaleOrReturn.Value = 1 Then   
    'that means that i'm buying from the supplier
    Me.stock.Value = (Nz(Me.stock.Value, 0) - Me.quantity.OldValue)
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
    Me.stock.Value = (Nz(Me.stock.Value, 0) + Me.quantity.Value)
    Else ' Here i'm returning articles to the supplier
    Me.stock.Value = (Nz(Me.stock.Value, 0) + Me.quantity.OldValue)
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
    Me.stock.Value = (Nz(Me.stock.Value, 0) - Me.quantity.Value)
    End If
    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:
    Code:
    Me.stock.Value = (Me.stock.Value - Me.quantity.OldValue)
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
    Me.stock.Value = (Me.stock.Value + Me.quantity.Value)
    Else
    Me.stock.Value = (Me.stock.Value + Me.quantity.OldValue)
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
    Me.stock.Value = (Me.stock.Value - Me.quantity.Value)
    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! :)
Working...