devxlogo

Display itemdata in a ComboBox

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 integerDim lEmpNum as DoublelEmpNum = rsEmp.Fields("emp_no").ValueFor q = 0 To cboComboBox.ListCount - 1  If cboComboBox.ItemData(q) = lEmpNum Then    cboComboBox.ListIndex = q    Exit For  End IfNext q

devx-admin

Share the Post: