Solved

Will combobox.ItemData accept a string

Posted on 2002-04-18
8
274 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 69

Expert Comment

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

Accepted Solution

by:
rkot2000 earned 50 total points
Comment Utility
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
Comment Utility
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
 
LVL 4

Expert Comment

by:nutwiss
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 5

Expert Comment

by:rkot2000
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks everyone

This was a great help

Merlin007
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

762 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

10 Experts available now in Live!

Get 1:1 Help Now