Assign Value to Second Column in ComboBox

schreinman

Registered User.
Local time
Today, 14:29
Joined
Oct 2, 2010
Messages
24
Can someone please let me know how to make this work:

Me.ComboBox.Column(1).Value = <some value>

I want to assign a visible value to the combo box where the first column width is set to 0. So only values assigned to the second column [column(1)] will be seen.

THANKS!!!
 
I'm not entirely sure I understand fully what it is you are trying to achieve :confused:

Can you possibly explain step by step what it is you are trying to do. A copy of your DB would also help (pre '07 if pos.)
 
I have a combobox with two columns. The width of the first column (the value I want to capture) is set to zero with the second column showing a concatenated version of the selection.

When a choice is requrired from this particular combobox I want to assign the "value" of "<select choice>" to the combobox. When I use the following code, "<select choice>" goes to the first column and since the first column is zero width it cannot be seen:

me.combo.value = "<select choice>"

So I need someone to explain to me how to assign "<select choice>" to the second column of the combobox so it will be visible.

Hope that helps clarify what I am trying to do.
 
Like John, I'm at sea as to exactly what you're trying to do! You can set the Value of a Combobox Control, which, in essence, moves the Combobox to that selection. To do this you have to set Focus to the Combobox first:

combo.SetFocus
me.combo.Value = "Whatever"


But you cannot assign a Value to the second Column of a Combobox because a Column does not have a Value Property! Which is why

Me.ComboBox.Column(1).Value = <some value>

doesn't work.

Your post is confusing because you say
When a choice is requrired from this particular combobox I want to assign the "value" of "<select choice>" to the combobox.

Essentially you're saying when a selection is made from the Combobox you want to assign that selection back to the Combobox.

You still need to clarify this further, perhaps with so sample data.

Linq ;0)>
 
It appears that what I was hoping to do can't be done based on your feedback; which is greatly appreciated by the way. In answer to the confusion, I wanted the selection in another combo box to result in the second combo box displaying "<select choice>", but because I have the width of the first (of two) columns in the second combo set to zero I don't see the assigned value.

Thanks all!!!
 
schreinmann

have a (locked) text box, controlsource set to =mycombobox - that will show you the hidden value.

you can "get at" any column of a combo box, even if hidden with

mycombobox.column(x)


the point is that the index is zero base, so the first column is column(0)


so
mycombobox
and
mycombobox.column(0) are the same
 
Basically you need to add <Select Choice> as one of the values in Column(1) of the RowSource. Use an out of scope value in the bound column of that entry and set that as the default.

To ensure the user has made a selection, test for that value in the BeforeUpdate procedure of the form and Cancel the update.

BTW, in answer to your original question. A value can be assigned to the other columns of a combo but not directly as you had hoped.

Basically you have to change the value in the combo's recordset. This can be rather clumsy if it is based on a RowSource query but somewhat easier if the combo's recordset is set directly to a recordset.

I often use ADO recordsets like this for combos and listboxes as it is a very versatile technique. It provides for reordering and filtering and allows all kinds of information to be displayed in the combo/listbox without having to ever hold it in a table.
 

Users who are viewing this thread

Back
Top Bottom