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!

Default value for Bound DBCombo box

Status
Not open for further replies.

xcmuchip

Programmer
May 31, 2001
70
I have a Bound DBCombo box where I would like to set a default value. I have tried to do this using the index property or datafieldtodisplay property. I have not had success. Anyone have some sample code? Or can I not do this with a bound dbcombo box. Currently the default value is the first value in the dropdown list.

TIA
 
Can you re-order the recordset so that the value you want appears first? I recently had the same sort of issue. I needed my list to display in a certain order, so I added a field to my table called seq_no. (sequence number) I set up my SQL statement to ORDERBY seq_no and then made sure that the sequence was set up in the table.

HTH
Ken ::)
 
Unfortunately it is not that simple. For example...

The combo box is a list of plants. It is one of the fields on a form. If the form comes up in "add mode", I want the combo box to be blank. Therefore, the user can use the drop down to select a plant for this new record. If the form comes up in "edit mode", I want the combo box value be a specific plant. These field values coming from a data grid.

Does this make sense?
 
If you have the DBCombo box set up correctly then what I had suggested should work fine. The way you described is how mine functions. I put the SQL statement with the recrodset object that populates the DBCombo's row source/list field and not the datasource/datafield settings.

I have my row source set to an MSRDC object. I then make sure that its SQL statement has the ORDERBY in it.

HTH
Ken ::)

ps. I played around a lot with this before I could get it to work so please feel free to ask as many questions a it takes to get yours working correctly!!
 
Here are my settings...

g_sSQL = "SELECT Name FROM Plant ORDER BY Name"
dtaPlant.DatabaseName = dbApp.Name
dtaPlant.RecordSource = g_sSQL
cmbPlant.DataField = "Name"
cmbPlant.DataFieldList = "Name"

There are no row source/list field properties for my dbcombo. I don't understand how you can setup a field for sequence number in your table. The value of this field would have to change depending on what record was being edited.
 
Just realized that you are talking about a DBCombo when I am using a SSDBCombo. They don't have the same properties.
 
I changed my object to a DBCombo (instead of SSDBCombo). All I had to do is change the style property to DropDownList and now it works the way I want.

Ken, thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top