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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select from Combo box and "auto-populate" 3

Status
Not open for further replies.

markswan20

Technical User
Jun 17, 2005
58
GB
This question has been asked but i need a little more information as i'm still struggling to answer it.

I have a combo box that i select one of two different products from. I have two columns within this combo box the first has the product description in the second has the price. When i select the relevant product it appears in the combo box. What i need is for the price to appear in a different box next to the combo box. This is where i'm stuck.

I have 2 tables in my database the first has all the relevant customer details the second has the products in can someone please help me in answering my question.

It will need to be answered in very simple terms preferable a walkthrough of what to type or where to put the information.

I look forward to someones response

Kind Regards
Mark
 
Hi

If you simply wish to DISPLAY the price, then create an unbound text box and set its Source to =YourComboboxname.Column(1)

If you wish to save the price in a (table) column, which is bound to your form, then in the AfterUpdate event of the Combo box put VBA code like so

YourPriceControlName = YourComboboxname.Column(1)

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Okay,

1) Open your form in design view.
2) Right-click on the combo and select "Properties"
3) Click on the "Event" tab
4) Click in the "After Update" field, then click the 3 ellipsis points to the right of the field. In the dialog that pops up, select "Code Builder"
5) A Visual Basic code window will open. Copy and paste the following code at the cursor:
Code:
Me![COLOR=red]txtMyTextBox[/color] = Me![COLOR=red]cboMyCombo[/color].Column([COLOR=blue][b]x[/b][/color])
6) In this code, replace the control names in red with the names of YOUR form's relevant controls. Replace x with the column number that holds the price data - but remember, column notation is zero-based and includes hidden columns. So Column(0) is the first column.
7) Click Debug->Compile on the menu. Save, and you should be good to go.

HTH,

Ken S.
 
One way would be to create an "After_Update" event for the product combo that would set the price in the text box.
i.e.
Sub cboProduct_After_Update()
Me.txtPrice = Me.cboProduct.Column(1)
End Sub

Note that the column is relative to zero.

Code: Where the vision is often rudely introduced to reality!
 
Thank you very much I now have a problem that has been bugging me sorted I send you all my thanks.

A very happy Forum Member
Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top