?
Solved

VB combobox

Posted on 2005-02-27
2
Medium Priority
?
162 Views
Last Modified: 2010-05-02
hi

Supposed i have a combo-box for selecting an Inventory Item ID....how can make the combo-box shows....example Item ID, Item Description, Item On hand, Item On Order, etc...in the drop-down list, but the user is actually only selecting the Item ID ?

0
Comment
Question by:Fiacre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Expert Comment

by:jkwasson
ID: 13415802
use the tag property of the combo box

with combo1
.additem "my first combo value"
.tag  = "my first combo id"
end with

hope this helps
jk
0
 
LVL 10

Accepted Solution

by:
fds_fatboy earned 200 total points
ID: 13417057
If the item id is an integer (including long), and assuming you are using VB (not access), you should use the ItemData property to hold the id. The tag won't work if you have more than one item in your combo box.



You use ItemData it like this:

    With Combo1
        .AddItem myItemDescription
        'Use NewIndex to reference Itemdata, in case Combo sorted property is set.
        .ItemData(.NewIndex) = myItemId
    End With

To get the current item's id:

    With Combo1
        If .ListIndex = -1 Then
            'Nothing selected
            MyID = -1 'Or another dummy value to indicate nothing selected
        Else
            MyID = .ItemData(.ListIndex)
        End If




If the id is not a long (integer) you might consider holding the id's in an array and using the Combo's ListIndex property to index the array. The problem with doing this however, is that it is difficult to implement if the sorted property id set on the combobox.

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.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

764 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