Keep Global Variables when code is being reset

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

Is there any way that any stored variables should be kept in memory even if
you have to reset your code due to a break. ?

Thanks in advance.


Scott
 
Scott said:
Is there any way that any stored variables should be kept in memory
even if you have to reset your code due to a break. ?

Not as such, no. There are a couple of approaches to this problem. One
is to save the information in controls on a form that remains open --
the form or the controls may be hidden. Another is to save the
information in a table, and reload it from the table whenever it appears
to have been lost. For example, you can use private variables in a
standard module to actually store the info, and use public Property Get
and Property Let procedures to retrieve or assign values. In those
procedures you can take care of saving modified data to a table and
testing for the need to reload values from the table.
 
If you place error handling in your code, then a runtime code-break/re-set
will NOT cause you globals to re-set.

Another approach is to always distribute a mde to your users. In the mde, a
run-time error DOES NOT re-set all your global vars. It is for this reason,
and many others that I ALWAYS distribute a mde to my users...and you should
too!
 
Back
Top