combo box help!

G

Guest

I have a Subform which contains a Combo Box with two columns - Products &
their Product code. I need a feature where I can select a product from the
list and it automatically drops the Product code into a Stock Code text box.
Any help would be appreciated,
 
G

Guest

You would want to use the OnUpdate event for the combo box, and populate into
your textbox. You would set your textbox value with the Value attribute, and
grab the Product Code using the Column method of the combobox control.

I hope this helps. I'm new here, so first post! Good luck.
 
G

Guest

Martin is spot on with his reply, but note that the Column property is
zero-based, so Column(0) is the first column and Column(1) the second. If
the code is in a hidden first column say, then the code for the control's
AfterUpdate event procedure would be along these lines:

Me.txtStockCode = Me.cboProducts.Column(0)

However I'm treating this as a potential Road to Dublin question and I'd
express a caveat here; only one of these controls should be bound to a field
in the underlying table. To have both the code and the product name in the
table would be redundant and leave the door open to update anomalies.
Normally in situations like this you'd just store the code in the table in
which case the combo box would be the bound control. You would not then need
any code to populate the unbound text box; just set its ControlSource
property to:

= cboProducts.Column(0)

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Populate another field using Combo Box 6
automatically update field 2
Help With MS Access 4
Combo Box 1
combo 1
ApplyFilterMacro 4
Combo Box very slow 1
store information in table 4

Top