[AccessD] Invalid Password

Heenan, Lambert Lambert.Heenan at chartisinsurance.com
Fri Oct 2 15:48:44 CDT 2009


Hi Max,

Indeed you can *declare* a Global (or a Public) variable in more than one regular module. But as soon as you try to *use* the variable the code line that does so will generate the  compile error: "Ambiguous name detected: YourVariableName" 

Interestingly 'Public' and 'Global' are not exactly the same thing, because if you try to declare a Global in the CBF then you will find that the IDE issues a compile error (as soon as you hit enter on the code line): 

Constants, fixed-length strings, arrays, user-define types and Declare statements not allowed as Public members of object modules"

 (as we know, form code modules are really Class (Object) modules.)

Yet you *can* declare a variable as Public in the CBF. Why the difference? Well something declared Public in a class module is a *member* of the class exposed to the outside. So if you have 

Public strFrmVariable As String

in a form named "MyForm", then the variable can be read and written to by code outside the form by fully referencing it...

Forms![MyForm]![strFrmVariable] = "You can change this data"

So even if two forms declare a Public variable with the same name, there is no ambiguity because the form names are different.

With standard modules it makes no difference if you use Global or Public in declaring variables. You can declare a variable Public in one module and Global in another or Public in both or Global in both. The effect is the same. The code *will* compile as long as the variable is not actually used. Make use of it anywhere and you will get that Ambiguous name compile error.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
Sent: Friday, October 02, 2009 3:48 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Invalid Password

Lambert,

Hi, it will take it if they are  both declared in modules and not CBF.
No error  given.  Eg:

Global xyz As String

Max


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert
Sent: 02 October 2009 20:27
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Invalid Password

??? " is it is, of course, possible to declare the same public variable in more than one place" ???

Do that and you will get a compile error: "Ambiguous name detected:
YourVariableName" 

Lambert




More information about the AccessD mailing list