Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble referencing Public Variables? 1

Status
Not open for further replies.

VoodooRage

Programmer
Oct 9, 2002
43
US
I have code running in a Private Sub where there are Public variables in the GENERAL section.

The code runs and opens a custom dialog box that allows the user to enter data. When the dialog closes I want to pass the data to the variables in the original module. For the life of me I can't get the data that is assigned from the dialog box to the public variables to actually work.

I can display the information when the dialog closes (using a msgbox) when I display the public variables (usning a msgbox) there are no values in the variables? The code is running correctly as far as sequence is concerned?

Any help would be appreciated as always!
 
The public variables are dim'ed once in the general section only (not within any sub)

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Yes the public variables are only declared in the general section of the first module.

The original module opens the custom dialog box, the data is entered, the box is closed and this is where the values are assigned to the public variables that should be able to display (msgbox) when the original code continues.
 
Are these Public variables declared with the Declarations section of a Form or a Code Module? There is a big difference between the two.

If they are in a Form module, then they are not global variables to the application, but rather they are Public properties of that Form object, which can be referenced, just as any other public property of an object, by using the ObjectName.Property.

On the other hand, if they are declared Public in the Declarations section of a standard code module, then they are global to the entire application.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
That is what I have been thinking. I am going to take the code out of the Private-Sub and place it in a module on it's own so that there will not be any trouble accessing the Public variables. I would like to thank everyone for thier help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top