Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field looks up value in a combo box

Status
Not open for further replies.

FranS37

Programmer
Jun 6, 2002
59
US
I have a subform with a combo box that displays a Product Name. The rowsource for the combo box is a SQL statement that has a ProductID and Unit Price in addition to the Product Name. The bound column is the Product ID. On the after update of the combox box, I want another field onthe subform - Unit Price - to display the Unit price for that Product Name. Any help?
 
Hi!

In the after update event, try:

[tt]me![Unit Price].Value=Me!ComboName.Column(1).Value[/tt]

Assuming the unit price is in the second column of the combo.

Replace ComboName with the name of your combo, use brackets if name includes spaces of special characters.

HTH Roy-Vidar
 
I get an error message "...can't find the macro me!UnitPrice. Does it matter that UnitPrice is a bound column? Does the field referenced in the combox box have to be the bound column? UnitPrice is not the bound column in the combo box.

Thanks for your help.
 
Hi!

It shouldn't matter if the unitprice is bound or unbound.

Have you used the button with the three dots at the right of the property window for the after update event? This hsould take you to the code window. Paste it there.

The reference in my initial reply, refers to the second column of the combobox. To refer to the bound column, it's sufficient with:

[tt]Me!ComboName ' or
Me!ComboName.Value[/tt]

Combos and list boxes are zero based, so referring to the value in the third column, could be:

[tt]Me!ComboName.Column(2)[/tt]

Roy-Vidar
 
Thanks for your help. I was putting it in the property window. When I moved it to the code window, it worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top