473,651 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global object instances get reset?

Hi all,

Currently, I'm working on an Access XP database app that uses two
global objects in its code. These two objects are instances of
"controller classes". For example, one of them manages the multiple
open instances of a form (some sort of 'window manager').

These global objects are created in a module "General", by defining
them with e.g.:

Dim VwMng As New KViewManager

Now there seems to be a bit of a problem with these global objects:
when I'm running the application, at random times Access crashes when
the code accesses these global objects. Apparently, the instances are
sometimes reset by Access --- even though I'm not working on the code
and haven't recompiled anything explicitly.

I also tried modifying the above code with...

Dim VwMng as KViewManager

....and then explicitly doing a "Set VwMng = New KViewManager" in the
AutoExec startup function. Same problem: completely at random, the
references seem to become invalid.

It seems that I've just taken Access too far, or made things overly
complicated or so... So now I'm working to rework the code, but this
global objects problem keeps popping up --- e.g. defining an instance
of the class Collection in a module results in the same problem:
sometimes the collection just vanishes into thin air, crashing Access.

Now I'm sure that there are people in here with a lot more experience
than I have :) Is there a workaround? Is it possible to reliably have
global objects? Or is it such a bad practice that I should be deeply
ashamed :) ?

Your help would be highly appreciated.. Thanks in advance!

Yours sincerely,
Onno Broekmans

Feb 4 '07 #1
24 3497
On Feb 4, 6:48 am, "onn...@gmail.c om" <onn...@gmail.c omwrote:
Hi all,

Currently, I'm working on an Access XP database app that uses two
global objects in its code. These two objects are instances of
"controller classes". For example, one of them manages the multiple
open instances of a form (some sort of 'window manager').

These global objects are created in a module "General", by defining
them with e.g.:

Dim VwMng As New KViewManager

Now there seems to be a bit of a problem with these global objects:
when I'm running the application, at random times Access crashes when
the code accesses these global objects. Apparently, the instances are
sometimes reset by Access --- even though I'm not working on the code
and haven't recompiled anything explicitly.

I also tried modifying the above code with...

Dim VwMng as KViewManager

...and then explicitly doing a "Set VwMng = New KViewManager" in the
AutoExec startup function. Same problem: completely at random, the
references seem to become invalid.

It seems that I've just taken Access too far, or made things overly
complicated or so... So now I'm working to rework the code, but this
global objects problem keeps popping up --- e.g. defining an instance
of the class Collection in a module results in the same problem:
sometimes the collection just vanishes into thin air, crashing Access.

Now I'm sure that there are people in here with a lot more experience
than I have :) Is there a workaround? Is it possible to reliably have
global objects? Or is it such a bad practice that I should be deeply
ashamed :) ?

Your help would be highly appreciated.. Thanks in advance!

Yours sincerely,

Onno Broekmans
The only times I've encountered this is when there is insufficent
error handling.
Any time you get the "Debug" / "End" option in an error message, the
code will inevitably stop running and everthing is reset.
Applying proper error handling will alert you to the error and handle
it without asking you what to do. Thereby not resetting project.

Feb 4 '07 #2
on****@gmail.co m wrote:
Now there seems to be a bit of a problem with these global objects:
when I'm running the application, at random times Access crashes when
the code accesses these global objects. Apparently, the instances are
sometimes reset by Access --- even though I'm not working on the code
and haven't recompiled anything explicitly.
Global variables are reset if there is an unhandled error. This doesn't occur in .MDE
files but does in .MDB files.

Add error-handling to appropriate procs.

Some classes can be re-instantiated but it doesn't sound like your class is a candidate if
it tracking other resources like open forms.

Public m_instanceYourC lass As clsYourClass

Public Function returnObjectRef () As clsYourClass

If (m_instanceYour Class Is Nothing) Then
Set m_instanceYourC lass = new clsYourClass
End If

Set returnObjectRef = m_instanceYourC lass
End Function

air code. Something like that but this is just curing the symptoms and not the disease ;)
--
'---------------
'John Mishefske
'---------------
Feb 4 '07 #3
Hi John and storrboy,

Thanks for your replies! I'm afraid, though, that the whole project
has already been filled with error handling :) I'm pretty sure there
are no unhandled errors occurring.

I will try using John's code, but I think I already tried it once, to
no avail.

Yours sincerely,
Onno Broekmans

Feb 5 '07 #4
Hm.. I also tried storing the 'global objects' on a form, but the same
problem keeps popping up: Access crashing at random when a global
object is accessed.

Is there anyone here who has used one or more global objects in a
module (like a Collection, or a home-grown object) with success? If
so, it would mean there may be some other problem in my code?

Thanks again,

Yours sincerely,
Onno Broekmans

Feb 5 '07 #5
on****@gmail.co m wrote:
Hm.. I also tried storing the 'global objects' on a form, but the same
problem keeps popping up: Access crashing at random when a global
object is accessed.
How did you do it?

When I follow this approach, I have a form, frmV (V for variables) with
numerous text boxes and possibly other controls on it. When I assign a
value to such a conytrol it's:

Forms.frmV.txtW indowsUserName = <whatever>

To access the variable in another form or module, I just refer back to
Forms.frmV.txtW indowsUserName
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Feb 5 '07 #6


In the Tools>Options menu, try changing the 'Break On' option to
Unhandled Errors.
See if you notice a difference in when and how many errors occur.

Try finding a method that repeates the error consistantly. Step
through the code and carefully check all your variable values and see
if you can identify what is actually causing it. This should at least
narrow down what to investigate next.

Feb 5 '07 #7
Hi Tim,
Hm.. I also tried storing the 'global objects' on a form, but the same
problem keeps popping up: Access crashing at random when a global
object is accessed.
How did you do it?
I declared a public variable:

Public ViewManager As CViewManager

in a form frmSys, which was opened during startup and then hidden
(Visible=False) . The variable was initialized in frmSys's Open event.
I also tried John's approach. It still seems Access 'randomly' resets
the project or so...

Yours sincerely,
Onno Broekmans

Feb 5 '07 #8
Hi storrboy,
In the Tools>Options menu, try changing the 'Break On' option to
Unhandled Errors.
See if you notice a difference in when and how many errors occur.

Try finding a method that repeates the error consistantly. Step
through the code and carefully check all your variable values and see
if you can identify what is actually causing it. This should at least
narrow down what to investigate next.
Thanks for the suggestion; I already have these settings set, though.
Perhaps I should indeed try stepping through the code some more. I
noticed some time ago, though, that when explicitly *stepping* through
the code in de debugger magically lets the errors disappear :)

I gave it some more thought, and it seems that most often pressing a
toolbar button causes the crash. Perhaps there could be some
(additional) problem regarding customized toolbars and toolbar buttons
bound to functions in a module?

Yours sincerely,
Onno Broekmans

Feb 5 '07 #9
On Feb 5, 2:00 pm, j.huibreg...@um ail.leidenuniv. nl wrote:
Hi storrboy,
......
>
I gave it some more thought, and it seems that most often pressing a
toolbar button causes the crash. Perhaps there could be some
(additional) problem regarding customized toolbars and toolbar buttons
bound to functions in a module?

Yours sincerely,

Onno Broekmans
I once also had problems with custom toolbars, but I can't recall if
it reset the project or not.
I found that both calling subs and using functions that return values
or accept arguments in a toolbar's action did cause problems.
I have since stuck with only calling functions specific to the button.

example...

Button action: =DoThis()

Function DoThis()
'Run the actual required proceedure using need arguments and return
values
End Function

Feb 6 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2186
by: Vani Murarka | last post by:
Hi Everyone, Does .NET offer any collection class which will give me objects last *accessed* such that I may build a least-recently-used cache that kills off objects that haven't been used for awhile? Or is there any other way to implement this kind of a cache / collection where one can do this kind of cleanup based on least-recently-used objects?
17
5613
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm constantly running tests on imperfect code. On of the cumbersome jobs encountered is reassigning global vars their values after a close encounter with an untrapped runtime error. Rather than writing a procedure to simply reassign them all with a...
33
3255
by: DFS | last post by:
An application I wrote has been deployed on Citrix, and the Citrix admin tells me all users run the same .mde file. There aren't a lot of concurrent users, but even 2 could be cause for concern. I think the use of globals is worrisome in this case. Anybody have any experience with Access on Citrix? (Al Kallal already griped me out about globals, but if he has anything new to add I'm all ears).
33
3034
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have been for years. If the machine has memory to spare and windows can use it - I'm thinking "Why not?" I was wondering what some of you have to say about that, particularly any severe "gotchas" you've had the unfortunate experience to contend with.
19
2057
by: Shiv Kumar | last post by:
I see that the Application_OnStart event is fired only once for a certain application. I'm interested in creating a "global" object (an object that will be available to all requests for the application). I thought I could use this event to create an instance of my object. I find that the event does get fired and an instance is created. However, when I reference this object from a page it is null. What gives? What is the recommended way...
15
2464
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 objects that the app used to speed up some global level data access and functionality. I have recoded the class libraries in .net and would like to acomplish the same functionality in asp.net.
1
6320
by: Stu | last post by:
Hi, Im using vis studio 2003 and I think wse is out of the question as clients could be using java which doesnt support it. So I managed to find some code which allows you to develop a custom soap header called by using a http module. The problem Im having is I cannot seem to get the event to raise to fire off my authenticate method in the global.asax. The module is plumbed in to my web.config file Code Below:-
23
2247
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 confused things, so I will start afresh. An example of what I want to do...
18
1613
by: Donn Ingle | last post by:
Hi, I'm getting myself really confused. I have three classes. Two of them need to reference the third, like so: Canvas ---Stack <--- Thing I am doing this right now: s = Stack()
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8694
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8571
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7294
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4143
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2696
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1905
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.