Unable to set Text property of a Combo Box

  • Thread starter Thread starter May
  • Start date Start date
M

May

Hi,

I'm trying to set Text property of a Combo Box and getting
an error message as below

"Run-tim error '2135'. This property is read-only and
can't be set."

Does anyone know that how I can set this property?
I have already set the Enabled & Visible propery be True
for the Combo Box, and have the Combo Box SetFocus before
I tried to set Text property.

Thanks in advance.

May
 
Hi May,

If you have a VB background then you need to know that the Text property in
Access is a bit different. The Value property is probably what you are
really trying to set and you don't even need to specify it explicitly since
it is the default property of the control. For example, either will work:

me.cboStuff=3
me.cboStuff.Value=3

The text Property in Access contains whatever has been typed into the
control, but not yet saved to the Value property of the control. This
property is only available when the control has the focus - which is
probably why you are getting the error.

Hope this helps,
 
Thanks Sandra.

I've tried to set the comboBox without specifiying the
properties, it doesn't allow me. I get the error message
as "Run-time error'-2147352567 (80020009)' You can't
assign a value to this object."

The RowSourceType of my comboBox is "Table/Query" and I
put the actual query in thh RowSource property. I'm not
sure if this is the reason that I can't assign a value to
the comboBox. In fact, the value that I'm assigning is
one of the item from the dropdown list which I get from
other table.

Again, before I assign the value to my combobox, I have
setFocus already.

Can you please give me more idea on what else I can do?

Thanks.
-----Original Message-----
Hi May,

If you have a VB background then you need to know that the Text property in
Access is a bit different. The Value property is probably what you are
really trying to set and you don't even need to specify it explicitly since
it is the default property of the control. For example, either will work:

me.cboStuff=3
me.cboStuff.Value=3

The text Property in Access contains whatever has been typed into the
control, but not yet saved to the Value property of the control. This
property is only available when the control has the focus - which is
probably why you are getting the error.

Hope this helps,

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Hi,

I'm trying to set Text property of a Combo Box and getting
an error message as below

"Run-tim error '2135'. This property is read-only and
can't be set."

Does anyone know that how I can set this property?
I have already set the Enabled & Visible propery be True
for the Combo Box, and have the Combo Box SetFocus before
I tried to set Text property.

Thanks in advance.

May

.
 
Hi May,

Just to be clear, you don't need to setfocus to the control in order to set
its value. That doesn't solve your problem but it is useful to know.

Post the code you are using to assign the value to the combo. Also be sure
to include the name of the combo, the field to which it is bound and any
other details that might be relevant to help explain the exact situation.
 
Thanks Sandra for getting back to me.

Below is the code to set property of the ComboBox and
assign value to the ComboBox.

FACILITY_COMBO.Enabled = True
FACILITY_COMBO.Visible = True
FACILITY_COMBO.SetFocus
FACILITY_COMBO = FACILITY_NUMBER

I'm getting the "Run-time error'-2147352567 (80020009)'"
in the assignment statement. Before the debugger steps
into the assignment statement, the
FACILITY_NUMBER.value="2099".

FACILITY_NUMBER is a field on the same form which is from
recordset of the form.

In the RowSourceType property of FACILITY_COMBO, I
put "Table/Query"
In the RowSource property of FACILITY_COMBO, I put "SELECT
LOCATIONTABLE.location, LOCATIONTABLE.locationname
FROM LOCATIONTABLE;"

In the ControlSource property of FACILITY_COMBO, I
put "=LOCATIONTABLE!location"

I hope I've given enough info for you to understand.
Thanks for your help.

May

-----Original Message-----
Hi May,

Just to be clear, you don't need to setfocus to the control in order to set
its value. That doesn't solve your problem but it is useful to know.

Post the code you are using to assign the value to the combo. Also be sure
to include the name of the combo, the field to which it is bound and any
other details that might be relevant to help explain the exact situation.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Thanks Sandra.

I've tried to set the comboBox without specifiying the
properties, it doesn't allow me. I get the error message
as "Run-time error'-2147352567 (80020009)' You can't
assign a value to this object."

The RowSourceType of my comboBox is "Table/Query" and I
put the actual query in thh RowSource property. I'm not
sure if this is the reason that I can't assign a value to
the comboBox. In fact, the value that I'm assigning is
one of the item from the dropdown list which I get from
other table.

Again, before I assign the value to my combobox, I have
setFocus already.

Can you please give me more idea on what else I can do?

Thanks.

.
 
Hi May,

Now I'm confused. I really don't understand what it is that you are trying
to do (this might have something to do with it being Friday afternoon :-)).
What recordset are you talking about?

If you put an expression in the controlsource of a control, you can not
assign a value it later. You can either leave the control unbound
(controlsource is empty) or bind it to a field, in which case the
ControlSource would have the field name with no equals sign (=) in front of
it.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Actually, what I want to do is to be able to modify the
FACITLITY_NUMBER in the recordset, the FACILITY_NUMBER is
actually from a lookup table (that's why I want to list
them in the Combo LOCATIONTABLE)

That's why I a FACILITY_NUMBER field which is storing the
facility_number from the record set, and copy the value
manually (when form is loaded) to a Combo, so that user
can make changes from the dropdown list. After the Combo
is changed, I will copy the value back to FACILITY_NUMBER
field so that the recordset can be updated.

I believe this is not unusual, but I don't know what I
should do to make it happen.

Thanks.

May
-----Original Message-----

Hi May,

If you have "=LOCATIONTABLE!location" in the Controlsource of the
Combo it is a calculated control and you can not assign a new value
to it in code. Is Location a field in the Recordsource query of the
form? If so, shouldn't the combo just be bound directly to that
field?

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Thanks Sandra for getting back to me.

Below is the code to set property of the ComboBox and
assign value to the ComboBox.

FACILITY_COMBO.Enabled = True
FACILITY_COMBO.Visible = True
FACILITY_COMBO.SetFocus
FACILITY_COMBO = FACILITY_NUMBER

I'm getting the "Run-time error'-2147352567 (80020009)'"
in the assignment statement. Before the debugger steps
into the assignment statement, the
FACILITY_NUMBER.value="2099".

FACILITY_NUMBER is a field on the same form which is from
recordset of the form.

In the RowSourceType property of FACILITY_COMBO, I
put "Table/Query"
In the RowSource property of FACILITY_COMBO, I put "SELECT
LOCATIONTABLE.location, LOCATIONTABLE.locationname
FROM LOCATIONTABLE;"

In the ControlSource property of FACILITY_COMBO, I
put "=LOCATIONTABLE!location"

I hope I've given enough info for you to understand.
Thanks for your help.

May

.
 
Hi Sandra,
Sorry, it must be me to confuse you!!!
Let me restate my situation here.

I have a table named MARKETTABLE, FACILITY_NUMBER is one
of the fields in MARKETTABLE record. I have another
lookup table named LOCATIONTABLE, LOCATIONID is one of the
fields in LOCATIONTABLE.
MARKETTABLE.FACILITY_NUMBER is referring to the lookup
table LOCATIONTABLE.LOCATIONID.
I have a query to select all records in MARKETTABLE,
FACILITY_NUMBER is one of the selected fields.
I want the user to be able to change
MARKETTABLE.FACILITY_NUMBER (which they can choose from
the LOCATIONTABLE.LOCATIONID).
This is why I have a Combo for LOCATIONTABLE.LOCATIONID,
and I also try to assign the MARKETTABLE.FACILITY_NUMBER
to the Combo (so that user knows what is the original
value of the MARKETTABLE.FACILITY_NUMBER, and what are the
choices they have to change to).

That's why the Combo must be bounded by

RowSourceType="Table/Query"
RowSource="SELECT LOCATIONTABLE.location,
LOCATIONTABLE.locationname FROM LOCATIONTABLE;"
ControlSource="=LOCATIONTABLE!location"

I hope I make it clearer this time.

Please let me know if you have any idea on my issue.
-----Original Message-----
Hi May,

Now I'm confused. I really don't understand what it is that you are trying
to do (this might have something to do with it being Friday afternoon :-)).
What recordset are you talking about?

If you put an expression in the controlsource of a control, you can not
assign a value it later. You can either leave the control unbound
(controlsource is empty) or bind it to a field, in which case the
ControlSource would have the field name with no equals sign (=) in front of
it.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Actually, what I want to do is to be able to modify the
FACITLITY_NUMBER in the recordset, the FACILITY_NUMBER is
actually from a lookup table (that's why I want to list
them in the Combo LOCATIONTABLE)

That's why I a FACILITY_NUMBER field which is storing the
facility_number from the record set, and copy the value
manually (when form is loaded) to a Combo, so that user
can make changes from the dropdown list. After the Combo
is changed, I will copy the value back to FACILITY_NUMBER
field so that the recordset can be updated.

I believe this is not unusual, but I don't know what I
should do to make it happen.

Thanks.

May
-----Original Message-----

Hi May,

If you have "=LOCATIONTABLE!location" in the Controlsource of the
Combo it is a calculated control and you can not assign a new value
to it in code. Is Location a field in the Recordsource query of the
form? If so, shouldn't the combo just be bound directly to that
field?

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


May wrote:
Thanks Sandra for getting back to me.

Below is the code to set property of the ComboBox and
assign value to the ComboBox.

FACILITY_COMBO.Enabled = True
FACILITY_COMBO.Visible = True
FACILITY_COMBO.SetFocus
FACILITY_COMBO = FACILITY_NUMBER

I'm getting the "Run-time error'-2147352567 (80020009)'"
in the assignment statement. Before the debugger steps
into the assignment statement, the
FACILITY_NUMBER.value="2099".

FACILITY_NUMBER is a field on the same form which is from
recordset of the form.

In the RowSourceType property of FACILITY_COMBO, I
put "Table/Query"
In the RowSource property of FACILITY_COMBO, I put "SELECT
LOCATIONTABLE.location, LOCATIONTABLE.locationname
FROM LOCATIONTABLE;"

In the ControlSource property of FACILITY_COMBO, I
put "=LOCATIONTABLE!location"

I hope I've given enough info for you to understand.
Thanks for your help.

May



.

.
 
Hi May,

I think you simply need to set the Controlsource of the combo to
Markettable.Facility_number (select it from the dropdown list in the
ControlSource property). That's probably all you need to do.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Hi Sandra,
Sorry, it must be me to confuse you!!!
Let me restate my situation here.

I have a table named MARKETTABLE, FACILITY_NUMBER is one
of the fields in MARKETTABLE record. I have another
lookup table named LOCATIONTABLE, LOCATIONID is one of the
fields in LOCATIONTABLE.
MARKETTABLE.FACILITY_NUMBER is referring to the lookup
table LOCATIONTABLE.LOCATIONID.
I have a query to select all records in MARKETTABLE,
FACILITY_NUMBER is one of the selected fields.
I want the user to be able to change
MARKETTABLE.FACILITY_NUMBER (which they can choose from
the LOCATIONTABLE.LOCATIONID).
This is why I have a Combo for LOCATIONTABLE.LOCATIONID,
and I also try to assign the MARKETTABLE.FACILITY_NUMBER
to the Combo (so that user knows what is the original
value of the MARKETTABLE.FACILITY_NUMBER, and what are the
choices they have to change to).

That's why the Combo must be bounded by

RowSourceType="Table/Query"
RowSource="SELECT LOCATIONTABLE.location,
LOCATIONTABLE.locationname FROM LOCATIONTABLE;"
ControlSource="=LOCATIONTABLE!location"

I hope I make it clearer this time.

Please let me know if you have any idea on my issue.
-----Original Message-----
Hi May,

Now I'm confused. I really don't understand what it is that you are
trying to do (this might have something to do with it being Friday
afternoon :-)). What recordset are you talking about?

If you put an expression in the controlsource of a control, you can
not assign a value it later. You can either leave the control unbound
(controlsource is empty) or bind it to a field, in which case the
ControlSource would have the field name with no equals sign (=) in
front of it.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Actually, what I want to do is to be able to modify the
FACITLITY_NUMBER in the recordset, the FACILITY_NUMBER is
actually from a lookup table (that's why I want to list
them in the Combo LOCATIONTABLE)

That's why I a FACILITY_NUMBER field which is storing the
facility_number from the record set, and copy the value
manually (when form is loaded) to a Combo, so that user
can make changes from the dropdown list. After the Combo
is changed, I will copy the value back to FACILITY_NUMBER
field so that the recordset can be updated.

I believe this is not unusual, but I don't know what I
should do to make it happen.

Thanks.

May
-----Original Message-----

Hi May,

If you have "=LOCATIONTABLE!location" in the Controlsource of the
Combo it is a calculated control and you can not assign a new value
to it in code. Is Location a field in the Recordsource query of the
form? If so, shouldn't the combo just be bound directly to that
field?

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this
newsgroup.


May wrote:
Thanks Sandra for getting back to me.

Below is the code to set property of the ComboBox and
assign value to the ComboBox.

FACILITY_COMBO.Enabled = True
FACILITY_COMBO.Visible = True
FACILITY_COMBO.SetFocus
FACILITY_COMBO = FACILITY_NUMBER

I'm getting the "Run-time error'-2147352567 (80020009)'"
in the assignment statement. Before the debugger steps
into the assignment statement, the
FACILITY_NUMBER.value="2099".

FACILITY_NUMBER is a field on the same form which is from
recordset of the form.

In the RowSourceType property of FACILITY_COMBO, I
put "Table/Query"
In the RowSource property of FACILITY_COMBO, I
put "SELECT
LOCATIONTABLE.location, LOCATIONTABLE.locationname
FROM LOCATIONTABLE;"

In the ControlSource property of FACILITY_COMBO, I
put "=LOCATIONTABLE!location"

I hope I've given enough info for you to understand.
Thanks for your help.

May



.

.
 
Thanks Sandra.
I tried, the Combo is now showing the
MARKETTABLE.FACILITY_NUMBER. However, I got another error
now when I try to select other value from the dropdown
list, which is "Control can't be edited; it's bound to the
expression 'FACILITY_NUMBER'". This message shows on the
Status Bar.
I have tried to change the ControlSource of the Combo in
the Click event, but it doesn't make any difference.
Do you have any idea how this can be solved?

Thanks.

May
-----Original Message-----
Hi May,

I think you simply need to set the Controlsource of the combo to
Markettable.Facility_number (select it from the dropdown list in the
ControlSource property). That's probably all you need to do.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Hi Sandra,
Sorry, it must be me to confuse you!!!
Let me restate my situation here.

I have a table named MARKETTABLE, FACILITY_NUMBER is one
of the fields in MARKETTABLE record. I have another
lookup table named LOCATIONTABLE, LOCATIONID is one of the
fields in LOCATIONTABLE.
MARKETTABLE.FACILITY_NUMBER is referring to the lookup
table LOCATIONTABLE.LOCATIONID.
I have a query to select all records in MARKETTABLE,
FACILITY_NUMBER is one of the selected fields.
I want the user to be able to change
MARKETTABLE.FACILITY_NUMBER (which they can choose from
the LOCATIONTABLE.LOCATIONID).
This is why I have a Combo for LOCATIONTABLE.LOCATIONID,
and I also try to assign the MARKETTABLE.FACILITY_NUMBER
to the Combo (so that user knows what is the original
value of the MARKETTABLE.FACILITY_NUMBER, and what are the
choices they have to change to).

That's why the Combo must be bounded by

RowSourceType="Table/Query"
RowSource="SELECT LOCATIONTABLE.location,
LOCATIONTABLE.locationname FROM LOCATIONTABLE;"
ControlSource="=LOCATIONTABLE!location"

I hope I make it clearer this time.

Please let me know if you have any idea on my issue.
-----Original Message-----
Hi May,

Now I'm confused. I really don't understand what it is that you are
trying to do (this might have something to do with it being Friday
afternoon :-)). What recordset are you talking about?

If you put an expression in the controlsource of a control, you can
not assign a value it later. You can either leave the control unbound
(controlsource is empty) or bind it to a field, in which case the
ControlSource would have the field name with no equals sign (=) in
front of it.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


May wrote:
Actually, what I want to do is to be able to modify the
FACITLITY_NUMBER in the recordset, the FACILITY_NUMBER is
actually from a lookup table (that's why I want to list
them in the Combo LOCATIONTABLE)

That's why I a FACILITY_NUMBER field which is storing the
facility_number from the record set, and copy the value
manually (when form is loaded) to a Combo, so that user
can make changes from the dropdown list. After the Combo
is changed, I will copy the value back to FACILITY_NUMBER
field so that the recordset can be updated.

I believe this is not unusual, but I don't know what I
should do to make it happen.

Thanks.

May
-----Original Message-----

Hi May,

If you have "=LOCATIONTABLE!location" in the Controlsource of the
Combo it is a calculated control and you can not assign a new value
to it in code. Is Location a field in the Recordsource query of the
form? If so, shouldn't the combo just be bound directly to that
field?

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this
newsgroup.


May wrote:
Thanks Sandra for getting back to me.

Below is the code to set property of the ComboBox and
assign value to the ComboBox.

FACILITY_COMBO.Enabled = True
FACILITY_COMBO.Visible = True
FACILITY_COMBO.SetFocus
FACILITY_COMBO = FACILITY_NUMBER

I'm getting the "Run-time error'-2147352567 (80020009)'"
in the assignment statement. Before the debugger steps
into the assignment statement, the
FACILITY_NUMBER.value="2099".

FACILITY_NUMBER is a field on the same form which is from
recordset of the form.

In the RowSourceType property of FACILITY_COMBO, I
put "Table/Query"
In the RowSource property of FACILITY_COMBO, I
put "SELECT
LOCATIONTABLE.location, LOCATIONTABLE.locationname
FROM LOCATIONTABLE;"

In the ControlSource property of FACILITY_COMBO, I
put "=LOCATIONTABLE!location"

I hope I've given enough info for you to understand.
Thanks for your help.

May



.

.

.
 
Back
Top