Ok I have a very simple DLookup function that I cannot figure out! I have an order detail subform in my order form and I just want the selected product to update the SalePrice field to the Price in the Product table.
I took the code directly out of the Northwinds database and changed the code to fit my fields:
With that code I get the error "You Cancelled the previous operation" If I remove the strFilter from the DLookup the error goes away, but it returns a value of $0.00.
Your thoughts are appreciated! Thank you!
I took the code directly out of the Northwinds database and changed the code to fit my fields:
Code:
Private Sub Product_ID_AfterUpdate()
On Error GoTo Err_Product_ID_AfterUpdate
Dim strFilter As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "Product_ID = " & Me!Product_ID
' Look up product's unit price and assign it to UnitPrice control.
Me!SalePrice = DLookup("[Price]", "Product", strFilter)
Exit_Product_ID_AfterUpdate:
Exit Sub
Err_Product_ID_AfterUpdate:
MsgBox Err.Description
Resume Exit_Product_ID_AfterUpdate
End Sub
With that code I get the error "You Cancelled the previous operation" If I remove the strFilter from the DLookup the error goes away, but it returns a value of $0.00.
Your thoughts are appreciated! Thank you!