Global variable resetting

  • Thread starter Thread starter Domac
  • Start date Start date
D

Domac

Hi,

When exception (debug or End) occur all of my global variable resets!
How to prevent it??
 
Hi Domac,

You may not be able to prevent global variables from losing their values,
but you can do a test just prior to referencing such a variable. Then
re-initialize the variable as needed. See my second post in this recent
thread:

http://www.microsoft.com/office/com...cess&mid=c6ccd43a-cd1e-4006-9f09-88035f2b9607


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Domac said:
Hi,

When exception (debug or End) occur
all of my global variable resets!
How to prevent it??

Generally, this happens only with "unhandled errors," so a good start would
be to include error handling everywhere an error could happen. That will
cover many of the cases, but it may be difficult to determine _all_ the
possibilities. If it's a production application used by others, it should
have user-friendly error handling, in any case. If it's your own
application, then you can live with losing the globals, or use another
option for storing them than global (Public) variables in a standard module.

Some other options are: save critical values in Controls on a
hidden/invisible Form; save the critical values in a Table; save critical
values in Properties of the database.

Larry Linson
Microsoft Access MVP
 

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

Back
Top