Autofill one field from a combo box value of another field

Killdozer

Registered User.
Local time
Today, 16:25
Joined
Jan 17, 2009
Messages
21
In my table, which is used to produce cost estimates. The two fields that I'm concerned with are: [Item], [Cost]. I have a combo box for [Item] which get the data from another table called "inventory" having two columns, Item, Cost.
Using a form based on the table, When making a selection from the combo box, the name of the item selected shows as the value. That's good so far.
Is it possible to have the [Cost] field populated with the dollar value of the item that was selected from the inventory table?
 
In the after update event of the combo:

Me.CostField = Me.ComboName.Column(1)
 
Hi, I tried what you suggested. My combo box is named: Combo23, My Cost field is called: RentalFees, So in the afterupdate of the event section of the combo23 properties, I typed:
Me.RentalFees = Me.Combo23.Column(1) I get an error as it cannot find the object Me. I attached an image of the error, not sure if you can see it.
 

Attachments

  • ME Error.png
    ME Error.png
    22.7 KB · Views: 260
Thanks Paul, you were right. So I created a new test table, and form with combo box, I no longer get errors, but the price is not showing in the Price field. The Combo box is called Combo6, having two columns: Item,Price.
The Table has three field: ID, Item, Price.
The form has the same as the table, plus the combo box.
This is the code written for the afterupdate event of the combo box:

Private Sub Combo6_AfterUpdate()
Me.Price = Me.Combo6.Column(2)
End Sub

Where am I going wrong?
 
It wasn't for nothing I put a 1 in the column property. ;)

That property is zero based, so 1 is the second column.
 
It wasn't for nothing I put a 1 in the column property. ;)

That property is zero based, so 1 is the second column.

Thanks, finally got it to work, I tried a 1 as well earlier, but no luck.
I got rid of the combo box from the form, and used the lookup in the table properties for the drop-down list. And I based my form directly on the table, not a query of the table as I tried previously

Thank-You very much for your help and patience.

Phil
 

Users who are viewing this thread

Back
Top Bottom