Keep Global Variables when code is being reset

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
 
D

Dirk Goldgar

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.
 
A

Albert D. Kallal

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!
 

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