How can I pass multiple values with a combo box

I have a combo box setup on a vb form. I need to populate another combo box based on the value selected in the first one.
How can i pass the id of a record along with the name with a combo box?

This is part of my code that populates the combo box,

    Dim cb As ComboBox
    Set cb = Me.Controls(strComboName)
    While Not recResult.EOF
        cb.AddItem recResult.Fields(0)  
    recResult.MoveNext
    Wend

In my program i can retrieve the value the user sees but i want to pass an id field along with every name displayed so i can use it to run another query.

Can somebody help with this?
dayikuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
There is an ItemData (long integer) property for each item in the list.
0
Shiju SasidharanAssoc Project ManagerCommented:
GrahamSkan is right

While Not recResult.EOF
        cb.AddItem recResult.Fields(0)  
        cb.ItemData(cb.NewIndex)= recResult.Fields(1)   ' Where  recResult.Fields(1) must be a integer or long data
       recResult.MoveNext
Wend
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shiju SasidharanAssoc Project ManagerCommented:
to retrieve it back use

        cb.ItemData(Index)
0
dayikuAuthor Commented:
Thanks for the information.
I tried to retrieve the value but it only gives me the last entry. I want the current selected value.
How do i do that?

eg    id =21343  Name=Dept1
        id =21445 Name=Dept2

When the user selects Dept1 i want the id.
0
dayikuAuthor Commented:
I just figured it out.

shijusn,
 TO retrieve value it should be cb.ItemData(ListIndex)


Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.