Public Variables

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

I have declared a public variable in the main switchboard form of my
application. All forms are 'Option Explicit'. The variable is declared as :

Public gCID as Integer

This variable is declared after the option explicit declaration within the
module for the siwtchboard form; however, when another form attempts to
access to update the value of this variable or display its current value, an
error occurs displaying "variable not declared".

Any ideas why this isnt working??
 
Try declaring the variable in a standard module instead of the class module
of the Switchboard form.

Choose the Modules tab of the Database window, and create a new module
there.

You may be able to reference the variable using a fully qualified name such
as:
Forms("Switchboard").gCID
or
Form_Switchboard.gCID
but these will not work as expected if the switchboard is closed, and could
be subject to instancing issues, so the standard module is a much better
approach.
 
I completely forgot that. I created a modDeclarations and put the
declarations all in that module. All is now working as it should. Thanks -
 
Back
Top