PDA

Click to See Complete Forum and Search --> : Display combo list data's primary key on text box


leeckeat
Aug 9th, 2000, 02:48 AM
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?

Paul Warren
Aug 9th, 2000, 08:05 AM
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 :

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.