Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB
Expertise: Advanced
May 10, 2005

Display itemdata in a ComboBox

This code shows how to display specific itemdata in a ComboBox. Currently, only the listindex property is available to navigate through a ComboBox.

' Consider a set of employee details
' EmpNum            EmpName
' 100               Tamara
' 101               Chidongo
' 102               Mphatso
' 103               Twiza

' When you select a record EmpNum = 102 from the database, and display
' it in a form, you may also want your combobox to display "Mphatso" 
' instead of  "Tamara" (listindex = 0). To display "Mphatso" in the 
' combobox:
'
Dim q as integer
Dim lEmpNum as Double

lEmpNum = rsEmp.Fields("emp_no").Value

For q = 0 To cboComboBox.ListCount - 1
  If cboComboBox.ItemData(q) = lEmpNum Then
    cboComboBox.ListIndex = q
    Exit For
  End If
Next q
Nkata Levi
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap