Need Help Creating Public Variables

  • Thread starter Thread starter Jim Evans
  • Start date Start date
J

Jim Evans

I have followed indtructions from 2 books to try to create a public variable
and assign a value to it in my start up form. When I try to reference the
variable from another form, the value is blank. Where can I find information
on doing this?

Jim Evans
 
Jim said:
I have followed indtructions from 2 books to try to create a public variable
and assign a value to it in my start up form. When I try to reference the
variable from another form, the value is blank. Where can I find information
on doing this?


Note that Public variables must be declared in the modules
declarations section, i.e. before any procedures.

If the variable is in the startup form's class module, then,
outside the startup form, you have to reference as a
property of the form:
Forms!startupform.variable

If the Public variable is declared in a standard module,
then you can reference it directly by just using its name
from any VBA code in your project, but not in control
expressions or in a query.
 
Marsh,

I hav them in the form Class Module. Moved the code to a Startup module and
all works as anticipated.

Thanks for your expedient help.

Another question...

When is the declarations section of a module read?

tia.

Jim Evans
 
Jim said:
I hav them in the form Class Module. Moved the code to a Startup module and
all works as anticipated.

Thanks for your expedient help.

Another question...

When is the declarations section of a module read?


It's not "read", it's part of the module that's just there
like the Function and Sub statements.

If you mean, when is it loaded into memory, I believe that
all versions since A2 wait to load a module until it is
first used.
--
Marsh
MVP [MS Access]


 
Back
Top