Global object scope problem
am 24.11.2007 10:07:30 von ApothecarySW
Hello all,
I have created a class to track the session details on a database we
use at work. The class stores information about the current user,
start time, end time, etc. The object instantiated from this class
works perfectly until I am closing the DB and then it disappears
before it can update the log table with the ending time. Here is a
brief summary.
The startup form is a hidden form that declares and sets the object in
the From_load. The properties are set and the table record written.
Then the main menu form is opened and the user does what ever they
need to do. When they exit the program, the hidden form is last to
close and the log table should be updated in the Form_unload
procedure.
Everything works correctly until I get to the From_unload. At that
point anything that includes reference to the session object's
properties or methods generates an error 91- object missing. I have
tracked the object properties in the Watch window and they exist
throughout the life of the program but disappear between the close
procedure of the main form and the Form_unload of the hidden form.
Why?
One of my many "fixes" was to move the object declaration to a
standard module used to define global constants and a few variable.
That made no change. I still get error 91.
Do "global" objects go out of scope before the form that created them
closes? Do I need to do the "set gobjSession = new clsSession" in a
different module?
I would appreciate any help or advice you can give me. I am using
Access 2003.
Thanks, Michael
Re: Global object scope problem
am 25.11.2007 00:33:57 von Tom van Stiphout
On Sat, 24 Nov 2007 01:07:30 -0800 (PST), ApothecarySW@gmail.com
wrote:
I never use a startup form, but rather an AutoExec macro that calls a
public function in a standard module. In that module global objects
get instantiated before at the bottom of the function I open the first
form.
-Tom.
>Hello all,
>
>I have created a class to track the session details on a database we
>use at work. The class stores information about the current user,
>start time, end time, etc. The object instantiated from this class
>works perfectly until I am closing the DB and then it disappears
>before it can update the log table with the ending time. Here is a
>brief summary.
>
>The startup form is a hidden form that declares and sets the object in
>the From_load. The properties are set and the table record written.
>Then the main menu form is opened and the user does what ever they
>need to do. When they exit the program, the hidden form is last to
>close and the log table should be updated in the Form_unload
>procedure.
>
>Everything works correctly until I get to the From_unload. At that
>point anything that includes reference to the session object's
>properties or methods generates an error 91- object missing. I have
>tracked the object properties in the Watch window and they exist
>throughout the life of the program but disappear between the close
>procedure of the main form and the Form_unload of the hidden form.
>Why?
>
>One of my many "fixes" was to move the object declaration to a
>standard module used to define global constants and a few variable.
>That made no change. I still get error 91.
>
>Do "global" objects go out of scope before the form that created them
>closes? Do I need to do the "set gobjSession = new clsSession" in a
>different module?
>I would appreciate any help or advice you can give me. I am using
>Access 2003.
>Thanks, Michael