pass two values from single combo box

BubBob

Registered User.
Local time
Today, 22:09
Joined
May 20, 2003
Messages
10
Is it possible, is there any way (VBA ?) to bound a combobox to two columns in a table. Or any other way to get values from two columns (same row of course)?
 
Bob,

Yes, you can get values from other columns. Look up "Row Source" and "Column Property" in Access Help (in that order).

Roughly, it goes like this: Say you fill your combo box using a query stored in the combo's row source property. And say your query has 5 columns: IDNum, Name, Address, City, Phone.

The IDNum is the table's primary key -- meaningful to you, meaningless to your users.
So you decide to use the combo box's column widths property to hide the first column and display only the last four columns: 0";1";1";1";1"

After a user makes a selection, the underlying value (not the same as the value that is visible in the combo) of your combo box will vary depending on the value found in your combo's Bound Column Property: If it's 1, Access will use the first column as the actual value. If it's 2, Access will use the second column as the actual value...etc.

Using code -- bound column or not, visible column or not -- you can get the value of any column in the row chosen by the user. (Yes, back to the original question.)

In this example, here's how the values would go:

IDNUM = Forms!FrmName!ComboName.Column(0)
Name = Forms!FrmName!ComboName.Column(1)
Address = Forms!FrmName!ComboName.Column(2)
City = Forms!FrmName!ComboName.Column(3)
Phone = Forms!FrmName!ComboName.Column(4)

Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom