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
See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist