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

Combo display Item & Cost

Status
Not open for further replies.

miletracker

Technical User
Apr 21, 2002
46
US
I need help with the following ,
I have a form "ExpenseEntry" (for adding expense Items )
bound to table "Expense"
with a combo that gets its values from a table named "Parts"(has part info and price)
when the user selects a part from "PartNameCombo" I need the Part name to show in the combo and the price to be displayed in the "Costtextbox" on the form.
Miletracker
 
You have several events in the combo box from which to chose; before update, after update, on change. You'll have to play with them to decide exactly which one you want to use.

Which ever you chose, you would open a recordset from the parts table selecting the price field where partNumber equals the value in the combo box. Then set the price field in the form equal to the price field in the recoreset.
 
Use the AfterUpdate event of the combo box PartNameCombo as grnzbra suggested.

If the PartNameCombo is based on Part Name and Cost, then in the AfterUpdate event, use the follwing code
Code:
CostTextBox = PartNameCombo(1)

Combo boxes are broken up into columns, so this statement tells CostTextBox to get the value of PartNameCombo's data in Column 1. Note Columns in text boxes start at zero. So in your case, you have two fields and want to get the second one (Cost), so you will use index (1).

Let me know if you have any questions.

Jay
 
Jay I have tried your suggestion and recieve the following error "runtime error #13 "Type mismatch" What is wrong ?????????
miletracker
 
Is the CostTextBox a bound control? If so, what is the datatype? What is the datatype for the Price?

Let me know and we will get it fixed.

Jay
 
Jay
it was my mistake The following works ok
Cost=PartName.Column(2) Thanks for pointing me in the right direction
miletracker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top