main form looses value when a popup window opens n closes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a main form from which I open a popup window. I have some variables
declared in my main form. I find that all the variables are initialised to
null once I open and close a popup window from the main form.

Is this the normal behaviour or am i doing something.

Thanks
raji
 
If your code has a runtime error, and you do NOT have error trapping in your
code, then all variables (both local, and global in scope) are re-set.

The mere fact of opening another form...doing something, and then closing
the form does NOT re-set variables.

Of course, that 2nd form can't *normally* use, or see the variables declared
in the main form.

However, when you return to the main form, the variables (both local to the
forms code) and global should remain. Of course, if you are using some
variables in a small code routine behind a button like:

Private Sub click1
dim strHello as string

strHello = "hello"

docmd.OpenForm "FormB"

Of course when you run the above, since the small code routine continues
execute AFTER the openform, then in fact we will have exited the above
routine..and strHello will not have a value anymore. If you move the
declaration of strHello to the forms module, (not the above local sub), then
in fact strHello WILL retain its value.

So, it is not clear if you are suffering from what is called varaibles going
out of "scope" (ie: the small sub has finished, so the variablesd are all
thrown out, or so called "out of scope"), or in fact you have some code that
causes a execution error that re-sets all values.

So, check the above two possible...
 
Back
Top