How to get the value at the second column of the ComboBox?

M

mezzanine1974

I have a ComboBox1 which has two column and the first columns is
bounded. Simply like that:

Supplier-ID Supplier Name
124556 Microsoft
236541 Apple

"Me.ComboBox1.Value" refers to Supplier-ID because it is bounded
column.
What kind of VBA statement can provide me the value of the second
column which is not bounded (Supplier Name)?
Is It possible?
 
K

Ken Snell \(MVP\)

Me.ComboBox1.Column(1)

Column is a zero-based property, so the first column is zero, the second
column is one, etc.
 
M

mezzanine1974

Thank you.. !
it is similar to Me.ComboBox1.ItemData(0). It returns the row values
instead.
 
K

Ken Snell \(MVP\)

ItemData returns the value of the Bound Column's data for a given row -- and
yes, it's also zero-based.
 
K

Ken Snell \(MVP\)

Also, you can use the Column property to get the value in any column in any
row, regardless of which "row" is currently selected in the combobox.

Me.ComboBox.Column(ColumnNumber_ZeroBased, RowNumber_ZeroBased)

Works for listboxes too.
 

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

Top