Link a text box to a combo box control

T

twen

If I have a combo box, cboControl and I want a text box to show the value so
it doesn't look like you can change it using the combo box, what is the code
for outputting column 2 of cboControl to a textbox txtControl.
I tried Me.txtControl = Me.cboControl.Column (2) but that didn't work, any
suggestions?
 
D

Douglas J Steele

The Column collection starts counting at 0, so the second column would be
Me.cboControl.Column(1)
 
S

Stefan Hoffmann

hi,
If I have a combo box, cboControl and I want a text box to show the value so
it doesn't look like you can change it using the combo box, what is the code
for outputting column 2 of cboControl to a textbox txtControl.
I tried Me.txtControl = Me.cboControl.Column (2) but that didn't work, any
suggestions?
Use as ControlSource for your Textbox "=cboControl.Column(2)", no VBA
needed.

Hint: if you have two columns in your Combobox then the index is Column(1).


mfG
--> stefan <--
 
R

Rick Brandt

twen said:
If I have a combo box, cboControl and I want a text box to show the
value so it doesn't look like you can change it using the combo box,
what is the code for outputting column 2 of cboControl to a textbox
txtControl.
I tried Me.txtControl = Me.cboControl.Column (2) but that didn't
work, any suggestions?

ComboBox columns are numbered starting with zero so you actually need Column(1).
Also you don't need any code. Just use...

=cboControl.Column(1)

....as the ControlSource of the TextBox.
 
Top