Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

Will combobox.ItemData accept a string

When I try to add a string to the ItemData array I get a type mismatch error. It accepts integers OK.

What is wrong.

Merlin007
0
merlin007
Asked:
merlin007
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
ItemData is a collection of LONG. You can't set it to strings.
0
 
rkot2000Commented:
if you want to store a string, you need to create an array of strings and store item index in the itemdata propery.

0
 
nutwissCommented:
yup.... unfortunately they're both right... it can be a pain..

I usually use the itemdata to store a bookmark from a recordset when the combo is populated, then if I wish to retrieve the record relevant to whatever is selected in the combo, I can simply use

Recordset.Bookmark = combo.itemdata(combo.listindex)
and pull whatever data direct from the recordset
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
nutwissCommented:
ps...my method is a little flawed before anyone points it out - as the bookmark property actually returns a double within a variant.
However with current versions of ADO, the value of the double is always integer, so I can use the itemdata property
<fingers crossed that this doesn't change in later versions...>
0
 
rkot2000Commented:
to nutwiss :
if it's a disconnected recordset you can store AbsolutePos.

p.s. you should not sort or filter your recodset after ...  
0
 
Arthur_WoodCommented:
nutwiss,  no need to worry, as THERE WILL BE NO LATER VERSIONS of VB... VB has been replaced by VB.NET, which allows the ItemData property to hold a OBJECT reference, so you can use almost ANYTHING you desire.  


Arthur Wood
0
 
nutwissCommented:
Yes, Arthur, i know - I meant any later versions of ADO :)
and rkot - I usually do filter or sort, that's why I use the bookmark...

Merlin, hope these suggestions help.
0
 
merlin007Author Commented:
Thanks everyone

This was a great help

Merlin007
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now