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.