Combobox ItemData

B

BananaQuaalude

Do comboboxes in Excel have an ItemData? I'm populating a combobox fro
a database and need to tie the record's UID to what's displayed in th
box.

Do I have to use multiple columns in the combobox to do this? And jus
hide that column maybe?

I know VBA pretty well, just have never used it in Excel before.

Thanks
 
R

Rob Bovey

Do comboboxes in Excel have an ItemData? I'm populating a combobox from
a database and need to tie the record's UID to what's displayed in the
box.

No. Unfortunately MSForms combo box controls lack this feature.
Do I have to use multiple columns in the combobox to do this? And just
hide that column maybe?

That's the easiest way to accomplish the same thing.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
B

BananaQuaalude

Thank you, Rob.

For some reason I didn't get notified by email when you posted this, s
I didn't see it until I checked the post just now.

So I'm taking the route of using multiple columns. When looping throug
a recordset to populate the combobox, how do I refer to a specifi
column?

Here's what I tried:

UserForm1.cboAccount.ColumnCount = 2
UserForm1.cboAccount.ColumnWidths = "2,0"

Do Until rs.EOF
UserForm1.cboAccount.column(0) = rs!acct_name
UserForm1.cboAccount.column(1) = rs!acct_id
'UserForm1.cboAccount.ListIndex = rs!acct_id
rs.MoveNext
Loop

But I think that's only for loading arrays. Is there a simple way t
load the two columns for each line?

Thanks
 
B

BananaQuaalude

Okay- disregard that last question. I figured it out:

Do Until rs.EOF
With UserForm1.cboAccount
.AddItem rs!acct_name
.List(.ListCount - 1, 1) = rs!acct_id
End With
rs.MoveNext
Loop

Thanks
 
B

BananaQuaalude

Okay- disregard that last question. I figured it out:

Do Until rs.EOF
With UserForm1.cboAccount
.AddItem rs!acct_name
.List(.ListCount - 1, 1) = rs!acct_id
End With
rs.MoveNext
Loop

Thanks
 
Top