Set control source =[cbxName].column(2)

J

Jack

In the control source of a textbox, is there a way to refer to a column of a
combobox? For example:
=[CbxName].Column(2)

Thanks,
Jack
 
M

Marshall Barton

Jack said:
In the control source of a textbox, is there a way to refer to a column of a
combobox? For example:
=[CbxName].Column(2)


Exactly like that. Just note that the column number is zero
based.

Did you try it? If it didn't work, what happened.
 
J

Jack

It didn't work. I got the #Name error.

The cbx has three columns, column count = 3, and I need to refer to the
third column.

This is in a subform where the subform is continuous.

Jack

Marshall Barton said:
Jack said:
In the control source of a textbox, is there a way to refer to a column of a
combobox? For example:
=[CbxName].Column(2)


Exactly like that. Just note that the column number is zero
based.

Did you try it? If it didn't work, what happened.
 
D

dixie

In the after update event of your combo box type in:

txtTextBoxName=cbxName.column(2)

That should do it.

dixie

Jack said:
It didn't work. I got the #Name error.

The cbx has three columns, column count = 3, and I need to refer to the
third column.

This is in a subform where the subform is continuous.

Jack

Marshall Barton said:
Jack said:
In the control source of a textbox, is there a way to refer to a column of a
combobox? For example:
=[CbxName].Column(2)


Exactly like that. Just note that the column number is zero
based.

Did you try it? If it didn't work, what happened.
 
M

Marshall Barton

#Name implies that you spelled the name of the combo box
incorrectly or left out the = sign.

However, this isn't going to do what you want in a
continuous (sub)form. All copies of the text box will
display the same value because there is only one combo box
control (the current record).
--
Marsh
MVP [MS Access]

It didn't work. I got the #Name error.

The cbx has three columns, column count = 3, and I need to refer to the
third column.

This is in a subform where the subform is continuous.

Jack said:
In the control source of a textbox, is there a way to refer to a column of a
combobox? For example:
=[CbxName].Column(2)

"Marshall Barton" wrote
Exactly like that. Just note that the column number is zero
based.

Did you try it? If it didn't work, what happened.
 
D

Douglas J. Steele

Perhaps the problem is the square brackets around the combo box name.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Marshall Barton said:
#Name implies that you spelled the name of the combo box
incorrectly or left out the = sign.

However, this isn't going to do what you want in a
continuous (sub)form. All copies of the text box will
display the same value because there is only one combo box
control (the current record).
--
Marsh
MVP [MS Access]

It didn't work. I got the #Name error.

The cbx has three columns, column count = 3, and I need to refer to the
third column.

This is in a subform where the subform is continuous.

Jack wrote:
In the control source of a textbox, is there a way to refer to a column of a
combobox? For example:
=[CbxName].Column(2)

"Marshall Barton" wrote
Exactly like that. Just note that the column number is zero
based.

Did you try it? If it didn't work, what happened.
 
M

Marshall Barton

Douglas said:
Perhaps the problem is the square brackets around the combo box name.

I don't think so Doug. The expression parser seems to add
(A97) and remove (AXP) square brackets at its own whim,
regardless of how it's originally typed.
 
D

Duane Hookom

A continuous form will correctly display the 3rd column for each different
record.

Make sure the name of the control is not also the name of a field.

--
Duane Hookom
MS Access MVP


Marshall Barton said:
#Name implies that you spelled the name of the combo box
incorrectly or left out the = sign.

However, this isn't going to do what you want in a
continuous (sub)form. All copies of the text box will
display the same value because there is only one combo box
control (the current record).
--
Marsh
MVP [MS Access]

It didn't work. I got the #Name error.

The cbx has three columns, column count = 3, and I need to refer to the
third column.

This is in a subform where the subform is continuous.

Jack wrote:
In the control source of a textbox, is there a way to refer to a column of a
combobox? For example:
=[CbxName].Column(2)

"Marshall Barton" wrote
Exactly like that. Just note that the column number is zero
based.

Did you try it? If it didn't work, what happened.
 
J

Jack

Thanks, Duane, for your response!

<<Make sure the name of the control is not also the name of a field.>>

Access defaults to naming a control the same as the name of the field. Why
does it have to be changed?

Jack



Duane Hookom said:
A continuous form will correctly display the 3rd column for each different
record.

Make sure the name of the control is not also the name of a field.

--
Duane Hookom
MS Access MVP


Marshall Barton said:
#Name implies that you spelled the name of the combo box
incorrectly or left out the = sign.

However, this isn't going to do what you want in a
continuous (sub)form. All copies of the text box will
display the same value because there is only one combo box
control (the current record).
--
Marsh
MVP [MS Access]

It didn't work. I got the #Name error.

The cbx has three columns, column count = 3, and I need to refer to the
third column.

This is in a subform where the subform is continuous.


Jack wrote:
In the control source of a textbox, is there a way to refer to a column
of a
combobox? For example:
=[CbxName].Column(2)


"Marshall Barton" wrote
Exactly like that. Just note that the column number is zero
based.

Did you try it? If it didn't work, what happened.
 
K

Ken Snell [MVP]

If you don't change it in this case, ACCESS will assume that you mean the
field to which the control is bound, not the control, and the code will
error because a field does not have a Column property.

--

Ken Snell
<MS ACCESS MVP>

Jack said:
Thanks, Duane, for your response!

<<Make sure the name of the control is not also the name of a field.>>

Access defaults to naming a control the same as the name of the field. Why
does it have to be changed?

Jack



Duane Hookom said:
A continuous form will correctly display the 3rd column for each
different
record.

Make sure the name of the control is not also the name of a field.

--
Duane Hookom
MS Access MVP


Marshall Barton said:
#Name implies that you spelled the name of the combo box
incorrectly or left out the = sign.

However, this isn't going to do what you want in a
continuous (sub)form. All copies of the text box will
display the same value because there is only one combo box
control (the current record).
--
Marsh
MVP [MS Access]


Jack wrote:
It didn't work. I got the #Name error.

The cbx has three columns, column count = 3, and I need to refer to the
third column.

This is in a subform where the subform is continuous.


Jack wrote:
In the control source of a textbox, is there a way to refer to a column
of a
combobox? For example:
=[CbxName].Column(2)


"Marshall Barton" wrote
Exactly like that. Just note that the column number is zero
based.

Did you try it? If it didn't work, what happened.
 
Top