Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a multi-column combo box to display text and hidden id

Status
Not open for further replies.

Tina22

Programmer
Nov 6, 2001
1
CA
I'm trying to make a vb application with Access tables and fill a mutli-column combo box without using the data control. I've made a connection to the database and used

cboWhatever.additem

to get one field in their but I need to display text like "description" but I want to access the record using its uniquie id. I've included the Microsoft Forms 2.0 Object library that has a multi-column combo box but I can't figure out how to load or manipulate it.

I don't want to connect it to a data control, I want to use code and fill it from the recorset that I've created from my database. The recordset contains 2 things.

rs(Description)
rs(InventoryID)

Thank you all for your time and any suggestions you have, I hope I've given enough info.
Tina
 
The ComboBox control on the VB IDE Toolbar has an ItemData property which lets you associate a 32-bit integer value with each item loaded in the ComboBox control. You could store the Inventory ID here and reference it from the ItemData property as needed.

If Not rs.EOF
Do While Not rs.EOF()
ComboBox1.AddItem rs("Description")
ComboBox1.ItemData(ComboBox1.ListCount = 1) = _
rs("InventoryID")
Loop
End If
 
CORRECT COPY:

The ComboBox control on the VB IDE Toolbar has an ItemData property which lets you associate a 32-bit integer value with each item loaded in the ComboBox control. You could store the Inventory ID here and reference it from the ItemData property as needed.

If Not rs.EOF
Do While Not rs.EOF()
ComboBox1.AddItem rs("Description")
ComboBox1.ItemData(ComboBox1.NewIndex) = _
rs("InventoryID")
Loop
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top