Link to home
Start Free TrialLog in
Avatar of tyy8
tyy8

asked on

Multi-Column ComboBox DefaultValue

I have a combobox with 2 columns. When its form is displayed. I want it's text value to already have a default in it, but I'm not sure what the delimiter is. With one column the defaultvalue could be (ex. "Hello") but with two - doing (ex. "Hello"; "World") does not put "Hello" in the first column and "World" in the next.
Avatar of BrianWren
BrianWren

Is this combo bound to the recordsource of the form?  Where dow it get the information that is in the drop-down list?

Brian
Avatar of tyy8

ASKER

its recordsource is a sql statement
What is the SQL?
Avatar of tyy8

ASKER

I think your taking the details of the situation far, far away from the question.

How do you fill the combobox's text value if it has two columns in it??

The recordsource doesn't matter.
A combo box can only have 1 bound column. It only displays the first visible column from the dropdown box in the control.

Your best bet is to make the sql query for the combo box concatenate the two columns into one. Make that one column the first visible.
OK, here's where I was going.

You cannot fill a combo box period.  All it has is its rowsource.

You can, however, position a combo box.

If there is a row in the rowsource of your combo box that has "Hello" in one column, and "World" in the other column, OF THE SAME ROW, then you can position the box on that row.

How that would be done depends intimately on how the rows are getting their data, hence the focus on the details.

Brian
tyy8:  I see where all the confusion is going on.  As I see it you want the combo box to default to a certain value.

If the combo box is bound, the default will only occur when you go to a new record.  If the default value is not one of the existing values in the combo box, it will not allow that setting unless the first field in the group is the bound field.  If the value does not exist and the not in list property is true, it will fuss that the value is not in the list.

Here are the scenarios:

If the default value is in the list, great!  You only need to have the first column in the default property.  That is what the field represents.  Forget the second value.  If you drop down the box, it will show up.

If the default value is not in the list and not-in-list is no, then there is no problem.

Same as last scenario but not-in-list is true, then you would have to create an union query with the first and second column values hand entered in the union query.  You still only need to have the first column value in the default box.

Jim
Avatar of tyy8

ASKER

Jim's correct, that works. Thanks to everyone.
ASKER CERTIFIED SOLUTION
Avatar of JimMorgan
JimMorgan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial