L
lisa09
Guest
Hi
I am a relatively new user to access and wondered if you could help me with a stock control problem.
I have created an update query (qryUpdateQuantityinStock) with the below fields:
QuantityinStock
tblProduct
Update: [QuantityinStock]-Forms!frmCustomerOrder![frmProductOrderLine Subform].Form!Quantity
ProductNumber
tblPrdocut
Criteria: [Forms]![frmCustomerOrder]![frmProductOrderLine Subform].[Form]![ProductNumber]
When the user enters the quantity they require into the orders form I would like to deduct it from the quantityinstock field in the products table.
The above query does work if you add the following code to the beforeupdate event of the orders subform:
If Me.NewRecord Then
DoCmd.SetWarnings False
DoCmd.openquery "qryupdateQuantityinStock"
DoCmd. Setwarnings True
End If
Although I wanted the query to run from a button (confirm order) on the order form so that the user decides when to deduct the stock.
I cannot put a button onto the orders subfrom where the query should run from and if I place the code on a button on the main orders form it only deducts one order (one product) and not all products on the order.
Can you help me find a way to run the query from a button?
I have read through the threads and found lots of information on stock control, although have not yet found anything similar to this problem. I understand that this is not the correct way to do stock control, although my database is for academic purposes and only requires a simple stock control system.
Any help would be greatly appreciated (sorry for the long post!).
Many thanks
I am a relatively new user to access and wondered if you could help me with a stock control problem.
I have created an update query (qryUpdateQuantityinStock) with the below fields:
QuantityinStock
tblProduct
Update: [QuantityinStock]-Forms!frmCustomerOrder![frmProductOrderLine Subform].Form!Quantity
ProductNumber
tblPrdocut
Criteria: [Forms]![frmCustomerOrder]![frmProductOrderLine Subform].[Form]![ProductNumber]
When the user enters the quantity they require into the orders form I would like to deduct it from the quantityinstock field in the products table.
The above query does work if you add the following code to the beforeupdate event of the orders subform:
If Me.NewRecord Then
DoCmd.SetWarnings False
DoCmd.openquery "qryupdateQuantityinStock"
DoCmd. Setwarnings True
End If
Although I wanted the query to run from a button (confirm order) on the order form so that the user decides when to deduct the stock.
I cannot put a button onto the orders subfrom where the query should run from and if I place the code on a button on the main orders form it only deducts one order (one product) and not all products on the order.
Can you help me find a way to run the query from a button?
I have read through the threads and found lots of information on stock control, although have not yet found anything similar to this problem. I understand that this is not the correct way to do stock control, although my database is for academic purposes and only requires a simple stock control system.
Any help would be greatly appreciated (sorry for the long post!).
Many thanks