473,320 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Global object scope problem

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
1 1569
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WhyteWolf | last post by:
I'm trying to set a object as global for access through out the rest of my script ... {a basic SQL accessing object} however if I try calling the object from with in another object it acts as if it...
8
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined...
2
by: Estella | last post by:
Hello, I wrote a function called eat_path() to split a string into components e.g. /a/b/c ==> namePtr = a,namePtr = a, namePtr = c // Global variable char *namePtr = {0}; int n; /*number of...
15
by: randyr | last post by:
I am developing an asp.net app based on a previous asp application. in the asp applications global.asa file I had several <object id="id" runat="server" scope="scope" class="comclass"> tags for...
16
by: Roman Ziak | last post by:
Hello, there were times when I used to be looking for a way to access JavaScript Global object similar to those found in VBScript or PHP ($GLOBALS). At present this has only academic value for...
23
by: David Colliver | last post by:
Hi, using c#, 1.1 I know that we are not supposed to use global variables etc. in c# I am having a problem, but not sure how to resolve. I did have another post here, but may have over...
3
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
6
by: Rajesh | last post by:
I read Global Object's constructor will be called before main() function; In which situation it can be really helpful? Is it good practice use Global object and its constructor ? Thanks,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.