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

Default combobox value 1

Status
Not open for further replies.

khowell78737

Programmer
Nov 18, 2003
22
US
I read the thread796-774766 that said that "comboName.Items.Insert(0,"Select")" would insert a "default" item at the top of the box.

Also in this thread, it mentioned that the insert must take place after the binding.

I'll be darned if I can get it to work.

My code is:
Public Function createStateCombo(byref combo as combobox)

<declarations and data retrieval code here>

combo.DataSource = ds.Tables("tblLookupState")
combo.ValueMember = "fldLuStateID"
combo.DisplayMember = "fldLuStateName"
combo.Items.Insert(0,"Select State")

<clean up code and error trapping here>
End Function

This does nothing but populate the combobox. There is no added item reguardless of where I put the insert line.

If I put the line in the calling procedre, I get an error that tells me I cannot insert when the datasource is set.

I'm missing something.. but what?

Thanks in advance!
Kevin Howell
























 
My opinion is when the combobox is bound to a datasource it can't accept insert statement. When the column in the database that bound to the combobox is updated then the combobox will update.

If you want to use the insert statement, you should use the "Do Loop" statement to add all the list items to the combobox. Of course you can pull data from the database and add to the combobox. After that you can use the insert statement.

Hope this help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top