Hey there, wondering if anybody can help me. I am designing a database similar to the example Northwind database. I used Northwind as a guideline as it is my first database. My Orders form and Orders Subform is basically the same as
northwind.
In the Orders Subform is use the following code:
Private Sub ProductID_AfterUpdate()
On Error GoTo Err_ProductID_AfterUpdate
Dim strFilter As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "ProductID = " & Me!ProductID
' Look up product's unit price and assign it to UnitPrice control.
Me!UnitPrice = DLookup("UnitPrice", "Price list", strFilter)
Me!CasePrice = DLookup("CasePrice", "Price list", strFilter)
Exit_ProductID_AfterUpdate:
Exit Sub
Err_ProductID_AfterUpdate:
MsgBox Err.Description
Resume Exit_ProductID_AfterUpdate
End Sub
When I run the orders form and click on the Product ID it gives me the following error:
"Data type mismatch in criteria expression"
The ProductID is a combo box with
the control source: ProductID
and the row souce: SELECT [ProductID], [ProductName] FROM Products ORDER BY [ProductName];
The difference between my ProductID and Nortwind's is that mine is a text value and theirs is a number.
Anybody with idea???PLZ
Yours Sincerely
BJ Steyn
northwind.
In the Orders Subform is use the following code:
Private Sub ProductID_AfterUpdate()
On Error GoTo Err_ProductID_AfterUpdate
Dim strFilter As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "ProductID = " & Me!ProductID
' Look up product's unit price and assign it to UnitPrice control.
Me!UnitPrice = DLookup("UnitPrice", "Price list", strFilter)
Me!CasePrice = DLookup("CasePrice", "Price list", strFilter)
Exit_ProductID_AfterUpdate:
Exit Sub
Err_ProductID_AfterUpdate:
MsgBox Err.Description
Resume Exit_ProductID_AfterUpdate
End Sub
When I run the orders form and click on the Product ID it gives me the following error:
"Data type mismatch in criteria expression"
The ProductID is a combo box with
the control source: ProductID
and the row souce: SELECT [ProductID], [ProductName] FROM Products ORDER BY [ProductName];
The difference between my ProductID and Nortwind's is that mine is a text value and theirs is a number.
Anybody with idea???PLZ
Yours Sincerely
BJ Steyn