Combo box columns

G

Guest

I have a combo box called cboEquip. Its row source is a query that selects a
couple fields from an equipment table. (I use the query because the
selection is based on certain criteria.) Anyway, cboEquip's droplist
displays the equipment description in column (0) & a unique equipment ID
number in column (1). The bound column is 1, which I believe equates to
column (0), and the droplist is sorted assending on the equipment ID.

Here's the problem. There is more than one piece of equipment of the same
description on the list. If I select a piece that is not the highest of its
kind on the list, the description displayed in cboEquip is correct but the
data I get from the following code reflects the ID of the piece of equipment
listed highest on the list.

Me.txtEquipID = Me.cboEquip.Column(1)

How can I get the equipment ID for the piece I selected?
 
A

Al Campagna

Del,
Set up the combo this way. This is the usual method, but you have a problem we'll
discuss afterwards...
Col 0 Col 1
EquipID EquipDesc

Combo bound to EquipID field of your table

Column count = 2
ColWidths = 0" ; 1.5" (adjust to suit)
List Width = 1.5"

This will allow the user to select by Desc, "display" that description in the combo, but
really store the EquipID in the EquipID field.

The problem occurs because you have duplicate EquipDescriptions. You'll can't tell
whether you have the correct Desc or not. (probably you are using the ID to assist you)
So... set the Column Widths to 1" ; 1.5" and ListWidth to 2.5". Youll see both columns,
and EquipID will still store in the EquipID field.

While this should work for you... I suggest you consider doing something to your
EquipDescs to differentiate them from one another... even if you have a unique EquipID
associated with them. It may cause more difficulties down thge line...
Your call...
 

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

Use combo box null as criteria in query 1
Append and Delete 1
nested queries 1
Cascade list/combo box 2
append query question 3
Left Join issues 1
my combo boxes 2
Need help with a date on a querie, please!!! 9

Top