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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Boxes, Additem

Status
Not open for further replies.

TimGoff

Technical User
Jul 16, 2002
166
GB
Hi,

I'm fiddled with Access a bit, and starting off with VB6

I'm adding items to a Combo box using additem

With rstChannels
Do While Not .EOF
frmMainForm!cboChannels.AddItem !Month
.MoveNext
Loop
End With

Can you add two column values to the Combo box, ie the ID value and another value eg Month, and then hide the key column like you can in Access?

Thanks in advance
tim
 
Look into the ListIndex property of the combobox. Only problem, it has to be an integer data type (Which sounds like it is ok for you, an ID, assuming it's a number).



Rob
 

Create a fabricated recordset(thread222-626165) with 3 fields, and when adding the data to the combo box, also add the list index and the two field values to the record.
Then, when an item is selected, use the ListBox selection index to do a rs.Find on the Index column with, in order to return the hidden "column".

If you are getting your data from a db Table, use the DataCombo where you can set the RowSource and ListItem and BoundColumn (don't worry, this isn't really bound to the db table with update capabilities unless you set the DataSource and DataField as well). The RowSource is the recordset, the ListField is the field which should be visible in the Combo(or your 2nd field) and the BoundColumn is then the hidden (first) field.

You return the selected item's first/hidden field using the BoundText property.
 
Hi, thanks for you post. I am sort of getting my head aroudn it, but have you any examples of this ? That would really help me understand it

Thanks
Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top