DLookup

  • Thread starter Thread starter Jon D.
  • Start date Start date
J

Jon D.

I have a products table with fields ProductID,
Description,Price. I also have an order details table
with fields orderID, ProductID,UnitPrice. My afterupdate
code to lookup price value for orderDetails.UnitPrice
looks like this: Dim strfilter as string
strfilter="productID=" & me.productID
me.unitPrice=dlookup("price","products",Strfilter)_
end sub

I am getting run time error 2001 previous operation
canceled. I really need to learn how to use the Dlookup
proficiently as it will be used in other parts of my
project.
Please Help!!
Thanks, Jon
..
 
Jon D. said:
I have a products table with fields ProductID,
Description,Price. I also have an order details table
with fields orderID, ProductID,UnitPrice. My afterupdate
code to lookup price value for orderDetails.UnitPrice
looks like this: Dim strfilter as string
strfilter="productID=" & me.productID
me.unitPrice=dlookup("price","products",Strfilter)_
end sub

I am getting run time error 2001 previous operation
canceled. I really need to learn how to use the Dlookup
proficiently as it will be used in other parts of my
project.

That looks ok to me except for the underscore at the end. Was that just a typo in
your post? Your syntax is correct if productID is a numerical value. If it's text
then you would need to add quotes around it.
 
Back
Top