Recommendation on calling module with public variables

L

laavista

I have public variables in a module. How do you recommend calling the module
so they are available throughout the Access session?

Should I call the module when in a form event, such as OnOpen or OnLoad?
If so, if the form is closed, when they still be available?

Thanks, in advance, for your help with this!
 
D

Dirk Goldgar

laavista said:
I have public variables in a module. How do you recommend calling the
module
so they are available throughout the Access session?

Should I call the module when in a form event, such as OnOpen or OnLoad?
If so, if the form is closed, when they still be available?

Thanks, in advance, for your help with this!


If these variables are defined in a standard module (not a class module),
then you don't need to do *anything* to call the module. The first
reference (after opening the database) to anything in the module, from
anywhere in the application, will cause the module to be loaded into memory,
where it will stay until the database is closed or the project is reset.
That means that a public variable in a standard module will retain its value
until you close the database, or have an unhandled error, or explicitly
reset the VB project.
 
L

laavista

Thank you. This was VERY helpful.

Dirk Goldgar said:
If these variables are defined in a standard module (not a class module),
then you don't need to do *anything* to call the module. The first
reference (after opening the database) to anything in the module, from
anywhere in the application, will cause the module to be loaded into memory,
where it will stay until the database is closed or the project is reset.
That means that a public variable in a standard module will retain its value
until you close the database, or have an unhandled error, or explicitly
reset the VB project.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top