DLookup

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
..
 
R

Rick Brandt

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top