Getting column data from selected item in combo box

T

Tim Rogers

I believe this is real simple, but for some reason I'm having
difficulty with it. I have a combo box and I want to get the value of
the bound column (0) in the combo box for the selected item. I tried
to do the following:

Dim iTopicId As Object
Set iTopicId = cmbTopIssues.Column(0)

I tried to make iTopicId an Integer and a Variant as well, but neither
worked. Although, I could do:

MsgBox cmbTopIssues.Column(0)

and the value would display just fine. So, I thought that Column()
returned a Variant. I believe my problem here is just a basic lack of
knowledge of VBA I suppose. Any help would be appreciated.

Thanks,

Tim Rogers
 
R

Rick Brandt

Tim Rogers said:
I believe this is real simple, but for some reason I'm having
difficulty with it. I have a combo box and I want to get the value of
the bound column (0) in the combo box for the selected item. I tried
to do the following:

Dim iTopicId As Object
Set iTopicId = cmbTopIssues.Column(0)

I tried to make iTopicId an Integer and a Variant as well, but neither
worked. Although, I could do:

MsgBox cmbTopIssues.Column(0)

and the value would display just fine. So, I thought that Column()
returned a Variant. I believe my problem here is just a basic lack of
knowledge of VBA I suppose. Any help would be appreciated.

Variant should have worked, but for that you don't want "Set" in front of
it. And if you want the bound column you shouldn't need a column qualifier
at all. Just use...

iTopicId = cmbTopIssues
 

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