assigning a value to a text box

J

Jeff

How do I set a value of a text box on a report??

In the reports report_open event I have txt_month.value = str_month
str_month is public from another form

error is: you can't assign a value to this object.
 
N

nickpup

I have this exact problem. Every method I've tried to
pass data to a report, which should be very simple does
not work. I understand that you have apparently posted a
solution but:

1) This does not seem at all logical. Why is a global
variable *not* recognized in a report?
2) Why can't you just set the value of the control as was
attempted below, for example in the open event? Why have
report controls with properties that can't be changed in
code? Why would Microsoft program an error message
like 'you cannot do that', with no reason or solution
given? What are we not understanding here?
3) Why does this work only from the format event? Where
is this documented, and if it is not, why not?

In other words, as a developer I abhor situations where
there is apparently devious weired behaviour that does not
make sense and can only be discovered through
extraordinary means. I have spent WAY too much time with
this very issue. Did I miss something or not understand
something?

Just curious.
 
M

Marshall Barton

The Open event is too soon to assign a control's Value
property. However, you can set several other
control/section properties in the Open event, including the
ControlSource property. Since the ControlSource property
determines how a control's Value is calculated, it's
necessary for this to be resolved before it can be
determined if a control is in fact unbound.

Forms have a Load event that is appropriate for assigning a
value to unbound controls. Since reports do not have a Load
event, you can use the Format event of any section that is
processed no later than the section containing the control.
 
J

Jeff

OK...What if I have a subreport with textboxes that I want to populate. Also
I have more than one occurrence of the subreport.

Marshall Barton said:
The Open event is too soon to assign a control's Value
property. However, you can set several other
control/section properties in the Open event, including the
ControlSource property. Since the ControlSource property
determines how a control's Value is calculated, it's
necessary for this to be resolved before it can be
determined if a control is in fact unbound.

Forms have a Load event that is appropriate for assigning a
value to unbound controls. Since reports do not have a Load
event, you can use the Format event of any section that is
processed no later than the section containing the control.
--
Marsh
MVP [MS Access]


I have this exact problem. Every method I've tried to
pass data to a report, which should be very simple does
not work. I understand that you have apparently posted a
solution but:

1) This does not seem at all logical. Why is a global
variable *not* recognized in a report?
2) Why can't you just set the value of the control as was
attempted below, for example in the open event? Why have
report controls with properties that can't be changed in
code? Why would Microsoft program an error message
like 'you cannot do that', with no reason or solution
given? What are we not understanding here?
3) Why does this work only from the format event? Where
is this documented, and if it is not, why not?

In other words, as a developer I abhor situations where
there is apparently devious weired behaviour that does not
make sense and can only be discovered through
extraordinary means. I have spent WAY too much time with
this very issue. Did I miss something or not understand
something?
 
K

Ken Snell [MVP]

Use the Format event of the subreport.

--

Ken Snell
<MS ACCESS MVP>

Jeff said:
OK...What if I have a subreport with textboxes that I want to populate. Also
I have more than one occurrence of the subreport.

Marshall Barton said:
The Open event is too soon to assign a control's Value
property. However, you can set several other
control/section properties in the Open event, including the
ControlSource property. Since the ControlSource property
determines how a control's Value is calculated, it's
necessary for this to be resolved before it can be
determined if a control is in fact unbound.

Forms have a Load event that is appropriate for assigning a
value to unbound controls. Since reports do not have a Load
event, you can use the Format event of any section that is
processed no later than the section containing the control.
--
Marsh
MVP [MS Access]


I have this exact problem. Every method I've tried to
pass data to a report, which should be very simple does
not work. I understand that you have apparently posted a
solution but:

1) This does not seem at all logical. Why is a global
variable *not* recognized in a report?
2) Why can't you just set the value of the control as was
attempted below, for example in the open event? Why have
report controls with properties that can't be changed in
code? Why would Microsoft program an error message
like 'you cannot do that', with no reason or solution
given? What are we not understanding here?
3) Why does this work only from the format event? Where
is this documented, and if it is not, why not?

In other words, as a developer I abhor situations where
there is apparently devious weired behaviour that does not
make sense and can only be discovered through
extraordinary means. I have spent WAY too much time with
this very issue. Did I miss something or not understand
something?

Ken Snell wrote:
Do it in the Format event of the section that contains
the textbox.

-----Original Message-----
How do I set a value of a text box on a report??

In the reports report_open event I have
txt_month.value = str_month
str_month is public from another form

error is: you can't assign a value to this object.
 
K

Ken Snell [MVP]

Sorry, I mean the Format event of the section in the subreport.

--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
Use the Format event of the subreport.

--

Ken Snell
<MS ACCESS MVP>

Jeff said:
OK...What if I have a subreport with textboxes that I want to populate. Also
I have more than one occurrence of the subreport.

Marshall Barton said:
The Open event is too soon to assign a control's Value
property. However, you can set several other
control/section properties in the Open event, including the
ControlSource property. Since the ControlSource property
determines how a control's Value is calculated, it's
necessary for this to be resolved before it can be
determined if a control is in fact unbound.

Forms have a Load event that is appropriate for assigning a
value to unbound controls. Since reports do not have a Load
event, you can use the Format event of any section that is
processed no later than the section containing the control.
--
Marsh
MVP [MS Access]



nickpup wrote:
I have this exact problem. Every method I've tried to
pass data to a report, which should be very simple does
not work. I understand that you have apparently posted a
solution but:

1) This does not seem at all logical. Why is a global
variable *not* recognized in a report?
2) Why can't you just set the value of the control as was
attempted below, for example in the open event? Why have
report controls with properties that can't be changed in
code? Why would Microsoft program an error message
like 'you cannot do that', with no reason or solution
given? What are we not understanding here?
3) Why does this work only from the format event? Where
is this documented, and if it is not, why not?

In other words, as a developer I abhor situations where
there is apparently devious weired behaviour that does not
make sense and can only be discovered through
extraordinary means. I have spent WAY too much time with
this very issue. Did I miss something or not understand
something?

Ken Snell wrote:
Do it in the Format event of the section that contains
the textbox.

-----Original Message-----
How do I set a value of a text box on a report??

In the reports report_open event I have
txt_month.value = str_month
str_month is public from another form

error is: you can't assign a value to this object.
 
J

Jeff

Ken, thanks for the help.
I am having a learning curve. It seems I can set text boxes on the main
report but what of the text boxes in the sub reports? I have tried:

Reports!rpt_calendar.Controls(subreport7).txb_Name1.Value = "12345"
does not work..."type mismatch"...any ideas


Ken Snell said:
Sorry, I mean the Format event of the section in the subreport.

--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
Use the Format event of the subreport.

--

Ken Snell
<MS ACCESS MVP>

Jeff said:
OK...What if I have a subreport with textboxes that I want to
populate.
Also
I have more than one occurrence of the subreport.

The Open event is too soon to assign a control's Value
property. However, you can set several other
control/section properties in the Open event, including the
ControlSource property. Since the ControlSource property
determines how a control's Value is calculated, it's
necessary for this to be resolved before it can be
determined if a control is in fact unbound.

Forms have a Load event that is appropriate for assigning a
value to unbound controls. Since reports do not have a Load
event, you can use the Format event of any section that is
processed no later than the section containing the control.
--
Marsh
MVP [MS Access]



nickpup wrote:
I have this exact problem. Every method I've tried to
pass data to a report, which should be very simple does
not work. I understand that you have apparently posted a
solution but:

1) This does not seem at all logical. Why is a global
variable *not* recognized in a report?
2) Why can't you just set the value of the control as was
attempted below, for example in the open event? Why have
report controls with properties that can't be changed in
code? Why would Microsoft program an error message
like 'you cannot do that', with no reason or solution
given? What are we not understanding here?
3) Why does this work only from the format event? Where
is this documented, and if it is not, why not?

In other words, as a developer I abhor situations where
there is apparently devious weired behaviour that does not
make sense and can only be discovered through
extraordinary means. I have spent WAY too much time with
this very issue. Did I miss something or not understand
something?

Ken Snell wrote:
Do it in the Format event of the section that contains
the textbox.

-----Original Message-----
How do I set a value of a text box on a report??

In the reports report_open event I have
txt_month.value = str_month
str_month is public from another form

error is: you can't assign a value to this object.
 
K

Ken Snell [MVP]

It sounds as if you're using the format event of the main report. I said to
use the format event of the subreport's section, not the main report's
section, when you want the subreport to set a value to its own textbox. And
there you'd just use this:
Me.txb_Name1.Value = "12345"

Also, your syntax for referring to a subreport's control is not quite right:
Reports!rpt_calendar.Controls("subreport7").Report.txb_Name1.Value =
"12345"

This assumes that subreport7 is the name of the control that holds the
subreport.

--

Ken Snell
<MS ACCESS MVP>


Jeff said:
Ken, thanks for the help.
I am having a learning curve. It seems I can set text boxes on the main
report but what of the text boxes in the sub reports? I have tried:

Reports!rpt_calendar.Controls(subreport7).txb_Name1.Value = "12345"
does not work..."type mismatch"...any ideas


Ken Snell said:
Sorry, I mean the Format event of the section in the subreport.

--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
Use the Format event of the subreport.

--

Ken Snell
<MS ACCESS MVP>

OK...What if I have a subreport with textboxes that I want to populate.
Also
I have more than one occurrence of the subreport.

The Open event is too soon to assign a control's Value
property. However, you can set several other
control/section properties in the Open event, including the
ControlSource property. Since the ControlSource property
determines how a control's Value is calculated, it's
necessary for this to be resolved before it can be
determined if a control is in fact unbound.

Forms have a Load event that is appropriate for assigning a
value to unbound controls. Since reports do not have a Load
event, you can use the Format event of any section that is
processed no later than the section containing the control.
--
Marsh
MVP [MS Access]



nickpup wrote:
I have this exact problem. Every method I've tried to
pass data to a report, which should be very simple does
not work. I understand that you have apparently posted a
solution but:

1) This does not seem at all logical. Why is a global
variable *not* recognized in a report?
2) Why can't you just set the value of the control as was
attempted below, for example in the open event? Why have
report controls with properties that can't be changed in
code? Why would Microsoft program an error message
like 'you cannot do that', with no reason or solution
given? What are we not understanding here?
3) Why does this work only from the format event? Where
is this documented, and if it is not, why not?

In other words, as a developer I abhor situations where
there is apparently devious weired behaviour that does not
make sense and can only be discovered through
extraordinary means. I have spent WAY too much time with
this very issue. Did I miss something or not understand
something?

Ken Snell wrote:
Do it in the Format event of the section that contains
the textbox.

-----Original Message-----
How do I set a value of a text box on a report??

In the reports report_open event I have
txt_month.value = str_month
str_month is public from another form

error is: you can't assign a value to this object.
 
N

nickpup

Ok - this should be clearly documented in the product.

Thanks,
Nick


Marshall Barton said:
The Open event is too soon to assign a control's Value
property. However, you can set several other
control/section properties in the Open event, including the
ControlSource property. Since the ControlSource property
determines how a control's Value is calculated, it's
necessary for this to be resolved before it can be
determined if a control is in fact unbound.

Forms have a Load event that is appropriate for assigning a
value to unbound controls. Since reports do not have a Load
event, you can use the Format event of any section that is
processed no later than the section containing the control.
--
Marsh
MVP [MS Access]


I have this exact problem. Every method I've tried to
pass data to a report, which should be very simple does
not work. I understand that you have apparently posted a
solution but:

1) This does not seem at all logical. Why is a global
variable *not* recognized in a report?
2) Why can't you just set the value of the control as was
attempted below, for example in the open event? Why have
report controls with properties that can't be changed in
code? Why would Microsoft program an error message
like 'you cannot do that', with no reason or solution
given? What are we not understanding here?
3) Why does this work only from the format event? Where
is this documented, and if it is not, why not?

In other words, as a developer I abhor situations where
there is apparently devious weired behaviour that does not
make sense and can only be discovered through
extraordinary means. I have spent WAY too much time with
this very issue. Did I miss something or not understand
something?
 
M

Marshall Barton

Well, Nick, for all we know it might be in the
documentation, but how does anyone go about finding it? I'm
pretty sure it was there back in A2 when there was real hard
copy, printed on paper documentation, but those days are
long gone :-(

OTOH, like I said earlier, it is the logical consequence of
documented features, so maybe they just expect you to deduce
it yourself :-\
 
Top