the variable and the textbox have different names.
You say that your textbox is unbound. Mine is bound to the variable. In
other words, in design view, the controlsource property is
"=myPublicVariable" (without the quotes). This results in "#Name?" being
displayed.
If I leave it unbound and assign to controlsource property in code using
this syntax, it works. But this is something i don't want to do because i'm
using someone else DB and i'll be getting updates regularly.
me.mycontrol.controlsource = "='" & myPublicVariable & "'"
tina said:
well, you're right on both counts - the property issue and the syntax. i ran
a quick test, setting the value of the public variable in the form's Open
event, and the unbound textbox control displayed the value just fine in Form
view. is your textbox control named the same as the variable? or do you have
another variable in the form, or in a standard module, named the same as the
one you're referencing in the textbox ControlSource?
hth
Chucky said:
As soon as a varialbe is declared Public it becomes available as a property
of the form.
:
Sounds as though it may have been set as a Property of the form, not simply
a variable. That's the only way I can think of that it would show up through
intellisense.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Well that's what i thought too and I have never referenced a variable
directly for a textbox controlsource. BUT, since it worked for the
developer
of the DB i researched it a bit more and found a few references where
people
said it should work if the variable is declared as Public in the form.
Also, in the form's VB module, if I type in "Me.", Intellisense
does
bring
up the public variable as a property of the form. That makes me think
that
it _might_ be referenced for the control source.
:
I don't understand how it could be working for anyone else, as Access
doesn't let you refer to variables like that.
Try creating a public function that returns the value of the variable,
and
use the function as the ControlSource.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Hi,
Access 2007
I have a form with a public variable called myPublicVariable.
The
form
has
a textbox. I want to use that public variable as the
controlsource
for
the
textbox. I believe it should work if the controlsource of the textbox
is
set
to "=[myPublicVariable]" but all I'm getting on the form is "#Name?".
The database was sent to us by someone else and it is working as
designed
for them. I have tried it on three machines here and they all
have
the
same
issue. Would a reference be the cause of this ?
I can get it to work using other methods but that would require editing
a
lot of forms and code and I'd rather not have to do this.
Thanks