Recommendation on calling module with public variables

  • Thread starter Thread starter laavista
  • Start date Start date
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!
 
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.
 
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)
 
Back
Top