I have created a subform based on a table. Within that table there is a
product name field which retrives a list of product names and prices from the
Products table. I to use the subform to enter product and then get it to
automatically update the price field.
I have read many entries about using after update to do this, but I just can
not get it to work. I select the product in the drop down and nothing
happens. I am pulling my hair out. The code I used was
Me.Product_Price = Me.Product_Name.Column(2)
Can any one help me
>I have created a subform based on a table. Within that table there is a
>product name field which retrives a list of product names and prices from the
[quoted text clipped - 8 lines]
>
>Can any one help me
Try this : After UpDate
Product_Price=DLookUp("Product_Price","ProductTableName","Product_Name=Name
of the field you used for the dropdown")
John - 22 Feb 2007 17:19 GMT
> >I have created a subform based on a table. Within that table there is a
> >product name field which retrives a list of product names and prices from the
[quoted text clipped - 13 lines]
> Product_Price=DLookUp("Product_Price","ProductTableName","Product_Name=Name
> of the field you used for the dropdown")
Ron2006 - 22 Feb 2007 21:23 GMT
Your original logic is almost correct. It is in the proper place BUT
The column numbers in combo boxes are based off of 0 not 1
So your original code is faster and better but should be:
Me.Product_Price = Me.Product_Name.Column(1)
The Dlookup will work but you are doing a whole extra query to get
something that you already have in the original query.
Column(1) is the second field in the combo query.
Ron
John - 26 Feb 2007 10:38 GMT
The method suggested by access monster seemed to work. Just could not get
your method working Ron. Thanks all the same
> Your original logic is almost correct. It is in the proper place BUT
>
[quoted text clipped - 10 lines]
>
> Ron
DubboPete - 26 Feb 2007 10:56 GMT
John,
try this code instead....
Product_Price = DLookUp("[ProductPrice]","ProductTableName","[Product_Name]
= [Forms]![FrmYourForm]![YourField]")
I hate DLookup, but manage to get by with this...
DubboPete