Public Variables

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??
 
A

Allen Browne

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.
 
D

Doug

I completely forgot that. I created a modDeclarations and put the
declarations all in that module. All is now working as it should. Thanks -
 

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