Combobox ItemData

  • Thread starter Thread starter BananaQuaalude
  • Start date Start date
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
 
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 *
 
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
 
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
 
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
 

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

Back
Top