Thank you in advance for your help!
I am Trying to create an update query that will change the value of a field in an OnUpdate Event.
Here is what I am trying to do.
I have a Form frm_NewOrderEntry that is bound to a Table tbl_Orders with a Primary Key of ID.
I have a Subform sfrm_NewOrderDetails that is bound to a Table tbl_OrderDetails with a Primary Key of ID and a Foreign Key of Order_ID.
In the Subform I have a Combo Box cbo_Product that does a lookup on a Table tbl_Products which is related to tbl_OrderDetails with a Foreign Key of Product_ID.
In the AfterUpdate Event for the Combo Box I Have the following code already.
Private Sub Product_ID_AfterUpdate()
txtDescription = DLookup("ProductDescription", "tbl_Products", "ID=" & Product_ID)
txtPrice = DLookup("RetailPrice", "tbl_Products", "ID=" & Product_ID)
txtQuantity = 1
txtDiscount = 0
End Sub
Table tbl_Products also has a Field ProductStatus_ID.
I would like an update query that can be triggered in the ONChange Event that changes the ProductStatus_ID Value for the Selected Product.
Here is what I have tried... but get an error.
Private Sub Product_ID_AfterUpdate()
Dim strSQL As String
txtDescription = DLookup("ProductDescription", "tbl_Products", "ID=" & Product_ID)
txtPrice = DLookup("RetailPrice", "tbl_Products", "ID=" & Product_ID)
txtQuantity = 1
txtDiscount = 0
strSQL = "UPDATE tbl_Products " & "SET ProductStatus_ID = " & 5 & " WHERE Product_ID = " & Product_ID
CurrentDb.Execute strSQL, dbFailOnError
End Sub
What have I done wrong?
Jason