Global and Public commands

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

I was wondering what the difference between a global and a public command.
For example:

Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3

This is one module

The other only saying public
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNORMAL = 1
Public Const SW_HIDE = 0
Public Const SW_SHOWMINIMIZE = 2

What I'd like to do is to put it in one Module if it can be done that way
hopefully there would be no mix up and confusion.

Thanks for reading this.
 
L

Linq Adams via AccessMonster.com

"Public" is usually used in Access, with "Global" still being supported,
probably for backwards compatibility.

Testing shows that they both work in the same manner.

I'd delete one of each duplicate, though, i.e.

Global Const SW_SHOWNORMAL = 1

and

Public Const SW_SHOWNORMAL = 1

While most developers use "Public," we still usually speak of "Global"
constants and variables, in conversation.
 
A

Afrosheen via AccessMonster.com

Thanks for getting back to me Linq

The global routines are from a function that clears the Access window for a
"Login" program.
The public routines are from a function that restores form size.

I thought that since they are in two different functions I could put them in
one function.
I was just wondering if I could get rid of one or the other.

Thanks again.
 
L

Linq Adams via AccessMonster.com

You can put whatever you want in a single standard Module. The only real rule
is that you cannot have two functions (or Constants) with the same name.

What Module Function, Constants and Variables are in is really a moot point,
as far as their being executed within Access. That's because when calling
these things the Module name isn't used. Different Modules are merely used as
a "filing" device, if you will. For instance, you might have a
modStringParsing to hold custom functions for parsing different types of
Strings, a modDates to hold Date handling routines, and so forth. But you
could also have a single Module to hold all of these. It doesn't matter when
Access calls a function.

One last note on Modules. Never, ever use the name of one of your functions
as the name of the Module as well. This confuses the Access Gnomes and will
cause an error to pop/
 

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