Global Variables Access 97

R

rysz_s

Hi All,

I'm trying to declare a global/public variable in a vba module of a specific
form so that the information contained can be read into a text box on another
form.

Any ideas anyone ?

Thanks for any help in advance.
 
A

Albert D. Kallal

If the form closes, then the variables will NOT exist anymore. (this is
called going out of scope).

So, if the form is still open, then simply reference the field you need.

forms!TheForm!ThetxtContorl

And, if for some strange reasons, you do in fact need to use the variable,
then you must prefix it with form name.

forms!TheOtherForm.MyGlobalVar

However, if the form is NOT opened, then your global var will NOT be
available.

You can either declare a global var in a standard module (and then have both
forms use that). When you do this, then no forms qualification is needed.


Or, as mentioned if the form is opened, then qualify the var as above

You can also pass a value from one form to anther via open args
 

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