View Full Version : using expressions in an update query


lugaburuga
03-22-2007, 10:17 AM
I want to be able to update stock levels by clicking a button on a form. The button executes code to run the updatequery. Details of Items are listed on a sales form. The fields include item code and quantity sold. Details of the items are stored in a table called 'Items' - fields include item code and quantity in stock. I want the clicking of the button to compare the item code in the form with the item codes in the Items table, and then reduce the quantity in stock by the quantity sold in the form.

Any help given would be much appreciated.

thanks

Moniker
03-22-2007, 12:08 PM
Link the two tables via the Item Code using an inner join. Make an update query on the Items table that says, "QuantityFieldName: [QuantityInStock]-[QuantityOnSalesForm]" (replacing as appropriate with the correct field names). Have the update query place the result of this expression in the Quantity field on the Items table.