Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Scope. 1

Status
Not open for further replies.

Ed2020

Programmer
Nov 12, 2001
1,899
GB
Anybody any idea what the difference between a Global variable and a Public variable is? As I understand it:

Dim - available only within the current procedure
Private - available to all procedures in the current module
Public - available to all procedures in all modules
Global - available to all procedures in all modules.

So what's the difference between Public and Global??

Ed Metcalfe.
 
Public is available to all procedures in all modules if in a module.
If a variable is declared as public from a class module, it is only available whilst the form or report to which the class module belongs is open.
Public class modules are referenced in the form of "Form_frmName.Variable"

James Goodman
 
Cheers James,

So if a variable is declared as Public in a standard module there is no difference between it and a Global variable?

Ed Metcalfe.
 
if you type in global, select it & then press F1, the access help loads the help file associated with the Public declaration. I would therefore assume Public & Global to be the same in their use. James Goodman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top