Displaying value of a variable on a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a bound form which has several text boxes, each box is for a date.
When the form opens, the Open event (through 5 IF statements) counts &
increments the number of these boxes that have null values. I have a
variable for this count. I would like to display the value of this count on
the form. I have a text box for this. At the end of the event, I set the
value of the text box = to the variable which is keeping count. The event
runs fine but on the form, the text box displays the following:

#Name?

Can anyone explain why this happens and how to correctly display the count?

TIA,
Rich
 
I figured it out. I had the name of the text box set the same as the name of
the variable. Changing the name of the text box resolved.

Lesson learned!!!

Thanks
 
check the following two issues:


1) - the on-open event is too soon to modify bound controls, and likely too
soon to modify un-bound controls. I would move this code to the on-load
event.

The on-open event has a "cancel" option, and allows you to 'test' conditions
of controls and do things in code, and if the form does not meet conditions
that you happy with, you can set cancel = true, and the form actually does
NOT load, or appear (nor does the forms on-load event/code run).

So, the on-open event is generally NOT used for code setup, and form setup
of values..it is ONLY for testing of conditions that would prevent the form
loading. So,move your code to the on-load event.


2) - the control in which your assigning a value is NOT un-bound, or in fact
is bound to some field, or expression that is incorrect.

If this is REALLY a un-bound contour, then you should not be seeing he
"name?". check the data tab of the properties sheet of this control...it
should be empty if it suppose to just display a value.

You can NOT bind a control on a form to a VBA variable. You have to use code
to assign he control, or you can bind that control to a function that
returns the value of the variable.
 
Back
Top