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?
Printable View
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?
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 :
Hope this provides the answer you need.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