Trapping Project Resets

K

Karim Virani

I'm having that annoying problem where a reset project clears all global
module variables. I want to be able to trap when an Access2K project has
been reset so that I can run some code to re-initialize these variables and
restart quiescent objects. There don't seem to be any hookable events in
the CurrentProject or Application objects that would help me out. How do I
do this?

Thanks

Karim
 
C

Chango V.

Different events can cause the globals reset, including "hard" errors. The
best way is probably just to check whether globals are initialized before
you proceed to use them. If, say, a reference is Nothing, assume you need
initialization. If you really want to detect a reset, try setting a
reference to a COM object in a global variable. The object should be
released and disposed of when the VBA project is reset (assuming there are
no other references to it elsewhere). If your COM object is implemented in
C++, your destructor will get called. (I believe there is an equivalent to
destructors in VB(A)--Terminate method?)

// Chango

NOTE: This post is from an anti-spam, non-existent email address. For
further communication, please reply to the Newsgroup and/or contact me
directly at (e-mail address removed).
 

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