update query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Draggonn
    New Member
    • Dec 2007
    • 10

    update query

    hello all. i'm having a problem with the update query. i have a table, which is products in stock. it has
    codep text primary key
    quantitystock number

    and then i have

    linearticle
    codec text (references commandes)
    codep
    quantitybought

    im currently using forms to fill out the tables.
    my problem is, that i can't figure out how to make the query get the codep i have currently open in the form, and then go to products table, and removes quantitybought from quantitystock
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Hi there,

    Assuming the fields, "codep" and "quantitybought " are on your form you could add the following line to the event you want the update triggered from.

    [code=vb]
    DoCmd.RunSQL ("UPDATE [products in stock] SET quantitystock = quantitystock - " & Me.[quantitybought] & " WHERE codep = '" & Me.[codep] & "'")
    [/code]

    This assumes your textboxes share the same names as the fields they represent.

    Comment

    Working...