Using the same variable in separate userform modules

D

DarrenW

Hello all,

Here's my question, I have created 2 userforms, the first is the main
one used simply for data entry and some calculations.

The second userform is called from the first userform using the Show
command, this is used to perform a simple search on the already
entered data and get a row number on a match.

I have defined 2 Public variables in the declarations section of the
first userform

Public CurRow as string
Used to store the row number

Public LoadJob as boolean
Used to tell if the user wants to load the data, True to load, False
to not load.

The Subs in the second userform module can see these variables and
assign them values (I'm assuming they can because I get no error
messages) however when I return to the first userform module after the
Show command the variables have been reset.

Are the assigned values only valid during the second modules scope of
operation?

Any ideas or suggestions would be appreciated

Thanks

DarrenW
 
P

papou

Hello Darren
Not too sure about public variables on userforms!
I would simply suggest that you declare these variables in the declarations
section of a standard module.
HTH
Regards
Pascal
 
J

Jose Rojas

try on Module1
Option Explicit

Public Type DistributorData
dName As String
dUserID As Long
End Type

and at the top of the form type
Dim Dist as DistributorData

J.Rojas
 

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