Solved

Will combobox.ItemData accept a string

Posted on 2002-04-18
8
280 Views
Last Modified: 2010-05-02
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
Comment
Question by:merlin007
8 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6951248
ItemData is a collection of LONG. You can't set it to strings.
0
 
LVL 5

Accepted Solution

by:
rkot2000 earned 50 total points
ID: 6951256
if you want to store a string, you need to create an array of strings and store item index in the itemdata propery.

0
 
LVL 4

Expert Comment

by:nutwiss
ID: 6951501
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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 4

Expert Comment

by:nutwiss
ID: 6951507
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
 
LVL 5

Expert Comment

by:rkot2000
ID: 6951527
to nutwiss :
if it's a disconnected recordset you can store AbsolutePos.

p.s. you should not sort or filter your recodset after ...  
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6951566
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
 
LVL 4

Expert Comment

by:nutwiss
ID: 6951614
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
 

Author Comment

by:merlin007
ID: 6951807
Thanks everyone

This was a great help

Merlin007
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now