Global variable

R

rcarson

I have forgotten how to declare a variable in a module as
a global variable whose value can be referenced from a
report, for example.

Any help? Thanks.

Rick
 
D

Dirk Goldgar

I have forgotten how to declare a variable in a module as
a global variable whose value can be referenced from a
report, for example.

Any help? Thanks.

Rick

Declare it at the module level, as Public:

Public gMyVar As ...

If the module is a standard module, that's all you need, and you can
refer to it with

X = gMyVar

If it's a form's class module, a reference to the variable must be
qualified with a reference to the open form; e.g.

X = Forms!MyForm.gMyVar
 

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