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

Create combo box based on value list 1

Status
Not open for further replies.

Terpsfan

Programmer
Dec 8, 2000
954
US
I want to be able to create a database combo box in which I use a value list instead of referencing a table. I'm able to do this in Access but haven't figured out how to do it in VB6. I have a form with several combo boxes and I simply want the user to select either "Yes","No","UTD". However I want that value reflected back to a field in the table. Because I will have so many combo boxes on my form I don't want the user to have to open up a table each time they select from the combo box. Any help will be appreciated. I tried the AddItem method on FormLoad but the values don't end up in the table.
 
If you have a datacombo you need to set the DataSource and Datafield properties so that the combo knows what source to update. The additem method only adds the items to the list, nothing else.

if you don't have a datacombo you need to create a function (connected to an event) that updates your records.
 
this is the way I do this;
the first thing I do is to make a small table in the database the has a column with the different items you want to appear in the list in the order you want them to appear in the list. Then you need to put an ADO Data Control on the form and set is connection string to the database and then set the recordsource to the table you want to update(call it adoDataSource).
Next add another ADO Data Control to the form and set the connection string to the database and set the recordsource to the table you created with the column of choices you want to present(call this one adoRecordSource). Now you can add a datacombo box to the form and set the datasource property to adoDataSource and the Rowsource property to adoRecordSource. Then set the BoundColumn property and the listfield property to the column you created in the new table, and then the datafield property to the field in the table where you want it to be updated to. run the form, it should give you your list and update your table when you invoke the update command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top