By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,212 Members | 1,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,212 IT Pros & Developers. It's quick & easy.

Global object scope problem

P: n/a
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

Nov 24 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Sat, 24 Nov 2007 01:07:30 -0800 (PST), Ap**********@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
Nov 24 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.