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

Getting bound column value

Status
Not open for further replies.

gharabed

Programmer
Joined
Sep 7, 2001
Messages
251
Location
US
I have a combo box with a valueList row source type and 2 column values in the row source. For example, the "RowSource" has values of "A;Car;B;Airplane;C;Train"

The boundColumn is "1" so that the "A,B,C" values are stored in the DB and the width of the first column is "0". How do I programatically (VBA) get the 2'nd column value? For example, lets say the value of the combo box is set to "A;Car" (in other words the word "Car" is displayed but the value "A" is what is stored). If I refer to the object [Forms]![MyForm]![MyCombo] in my VBA code then I get a value of "A". How do I get the value of "Car" to return?

Thanks,
Greg
 
MyCombo.column(1)

The first column is counted as column zero.

HTH

John
 
A better technique is to store the values and their definitions in a separate table:

Mode Table
Identifier Literal
A Car
B Train
C Airplane
D Spaceship

Set your combo box to two columns, bind the first column (A,B,C,D) and set its column width to zero. This will display the literal choices in the combo box, but bind the identifier to the value of the control which should be stored in the ControlSource.

When you then want the literal value you can use:

=DLookup("LiteralValue", "ModeTable", "Identifier = Forms!MyForm!MyComboBox")

Uncle Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top