Results 1 to 2 of 2

Thread: Display combo list data's primary key on text box

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    Penang, Malaysia
    Posts
    51

    Exclamation

    I have 2 attribute - CustomerCode , CustomerName.
    In the combo list, i list out all the CustomerName from database. When user choose one of the data in combo list, how can i display the primary key of customerName (CustomerCode) on another text box?

  2. #2
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282

    Use ItemData

    Each combobox ( and listbox ) has a property called ItemData which can be used to store a peice of info for each item in the vivsible list. Think of it as a Tag property for every item you display. So, to display the customer ID use :
    Code:
    Private Sub Combo1_Click()
    
    ' When the user clicks on Hello the itemdata is shown in the textbox
    Text1 = Combo1.ItemData(Combo1.ListIndex)
    
    End Sub
    
    Private Sub Form_Load()
    
    Combo1.AddItem "Hello"
    Combo1.ItemData(Combo1.NewIndex) = "1234"
    
    End Sub
    Hope this provides the answer you need.
    That's Mr Mullet to you, you mulletless wonder.

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