Results 1 to 3 of 3

Thread: Combobox with two parts of information

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Dear VB users,

    I am making a combobox with two types of information.
    The first kind of information is a name, the second one is an ID to a database.
    In priciple I don’t want to see the ID in the combobox. After selecting I want to see my name inclusive the ID number.

    Can someone give me a solution??

    Nice regards,

    Michelle.

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    michelle, All you need is juz make use of the ComboBox's ItemData properties to store the ID.

    Code:
    Private Sub Combo1_Click()
        MsgBox Combo1.Text & " --- " & Combo1.ItemData(Combo1.ListIndex)
    End Sub
    
    Private Sub Form_Load()
    Dim n As Integer
        With Combo1
            For n = 0 To 10
                .AddItem "Item " & n
                .ItemData(n) = n
            Next
        End With
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Hello Chris,

    Thanks you very much for your information.

    Michelle.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width