Lookup Combo Boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to select from a combo box list in a form a product, and
it's price to show up in a separate field in the same form. I can't seem to
find this demonstration on how to do so. I've read the entire
"Comprehensive" version book about Access and done the exercises and have
found nothing regarding this task.

I have have a table with a product name and price. Is there a way to have
the price field to equal a particular value associated with the product if it
is true?
 
I assume your combo box row source is based on your "table with a product
name and price". Add the price as a column in the row source. You can then
add a text box to your form that displays the price column with an expression
like:
=cboProduct.Column(1)
Columns are numbered beginning with 0. This makes the "price to show up in a
separate field in the same form". It really isn't a "field". It's a text box
that displays on a form.
 
Duane:

I'll give this a try. I was able to do what I wanted with a query, but it
wouldn't show up in the form as I wanted. I will try to learn more about the
code. The closest I have come to any type of formulated code is Excel.

Happy Holidays, and thanks for your advice and patience!

Duane Hookom said:
Code is your friend ;-)
You need to be in design view of your form. Double-click your combo box to
display the properties dialog. Change the name of the combo box to cboFeet.
Find the Event properties tab and then the After Update property.
Double-click this property to display:
After Update....... [Event Procedure]
Click the ellipsis [...] button to display the code window:

Private Sub cboFeet_AfterUpdate()

End Sub

Type one line of code in the middle to result in something like:
Private Sub cboFeet_AfterUpdate()
Me.txtFeetPrice = Me.cboFeet.Column(1)
End Sub

This assumes your combo box is named cboFeet and has the price in the second
column. It also assumes your Feet Price text box is named "txtFeetPrice".

Compile your code to check for errors by clicking Debug->Compile...

If you don't get any errors, close the MS Visual Basic window and save your
form.
If you get errors, the you need to fix them or come back with your code,
error message, control names,....
--
Duane Hookom
Microsoft Access MVP


EZ KEY said:
Thanks Duane! This is helpful, but I guess I need to understand more about
"code" which I do not know anything about. I'm probably going to have to
find a class somewhere to learn more.

Thanks for the help and suggestions!
 
Back
Top