Hi
Not being an expert, I have taken Northwind's approach to Dlookup, which works fine for BLPEuPrice, see below.
I have tried the same for a different field in another table (Tbl_ProdCat4) but it returns always the last row value for the field InvFactor from Tbl_ProdCat4.
I have a few one to many tables each providing a level of product categorisation or hierarchy and at the highest level 4, each category has a different invoice factor.
Please help, I am lost at this point...
Sub ProdID_AfterUpdate()
On Error GoTo Err_ProdID_AfterUpdate
Dim strFilter As String
Dim StrFilter2 As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "ProdID = " & Me!ProdID
StrFilter2 = "ProdID = " & Me!ProdCat4ID
' Look up product's unit price and assign it to UnitPrice control.
Me!OrDetInvFactor = DLookup("[InvFactor]", "Tbl_ProdCat4", StrFilter2)
Me!BLPEuPrice = DLookup("BLPEu", "Tbl_Prod_Cong", strFilter)
Exit_ProdID_AfterUpdate:
Exit Sub
Err_ProdID_AfterUpdate:
MsgBox Err.Description
Resume Exit_ProdID_AfterUpdate
End Sub
Not being an expert, I have taken Northwind's approach to Dlookup, which works fine for BLPEuPrice, see below.
I have tried the same for a different field in another table (Tbl_ProdCat4) but it returns always the last row value for the field InvFactor from Tbl_ProdCat4.
I have a few one to many tables each providing a level of product categorisation or hierarchy and at the highest level 4, each category has a different invoice factor.
Please help, I am lost at this point...
Sub ProdID_AfterUpdate()
On Error GoTo Err_ProdID_AfterUpdate
Dim strFilter As String
Dim StrFilter2 As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "ProdID = " & Me!ProdID
StrFilter2 = "ProdID = " & Me!ProdCat4ID
' Look up product's unit price and assign it to UnitPrice control.
Me!OrDetInvFactor = DLookup("[InvFactor]", "Tbl_ProdCat4", StrFilter2)
Me!BLPEuPrice = DLookup("BLPEu", "Tbl_Prod_Cong", strFilter)
Exit_ProdID_AfterUpdate:
Exit Sub
Err_ProdID_AfterUpdate:
MsgBox Err.Description
Resume Exit_ProdID_AfterUpdate
End Sub