Problem with AddItem


I'm attempting something that should be very simple, but is turning out not to be.  Here's the line that works:

            cboSolutions.AddItem rsCase("Solution_Description")

where "Solution_Description" is a large string.  cboSolutions. is a standard combo box.

I've decided I want to add the ID in to the index field of the combo with each string entry, so I tried:

             cboSolutions.AddItem rsCase("Solution_Description"), rsCase("Solution_ID")

where "Solution_ID" is an integer.  It didn't like this at all.  I expermented by putting a straight integer in the second field, and by putting a string literal in the first field after that.

What am I missing?
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.

Use ItemData property:

cboSolutions.AddItem rsCase("Solution_Description")
cboSolutions.ItemData(NewIndex) = rsCase("Solution_ID")
The second parameter specifies an existing position in the list, so must not equal or exceed the number of items.
NigelRocksAuthor Commented:
Where do you get the "NewIndex" variable?
Sorry. Failed to test. It's a property of the combo control, meaning the index of the last item added.
cboSolutions.AddItem rsCase("Solution_Description")
cboSolutions.ItemData(cboSolutions.NewIndex) = rsCase("Solution_ID")

Open in new window


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
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.