• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

VB combobox

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
Fiacre
Asked:
Fiacre
1 Solution
 
jkwassonCommented:
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
 
fds_fatboyCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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