After update Not update Text Field

J

John

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
 
D

destinman via AccessMonster.com

John said:
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



Try this : After UpDate

Product_Price=DLookUp("Product_Price","ProductTableName","Product_Name=Name
of the field you used for the dropdown")
 
J

John

destinman via AccessMonster.com said:
Try this : After UpDate

Product_Price=DLookUp("Product_Price","ProductTableName","Product_Name=Name
of the field you used for the dropdown")
 
R

Ron2006

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
 
J

John

The method suggested by access monster seemed to work. Just could not get
your method working Ron. Thanks all the same
 
D

DubboPete

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
 
Top