473,386 Members | 1,860 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,386 software developers and data experts.

Unhandled errors; public vars/classes lose scope??

Why do my public variables (including class instances) disappear when
my app experiences an unhandled error?

My custom class module's class_terminate event doesn't even fire, the
instance just goes out of scope/gets garbage collected/disappears into
thin air.

Does anyone know why Access behaves in this manner, or more
importantly how to change that behavior?

FYI I am using an AutoExec macro to call a public function (in a
module) that creates an instance of a custom class (to keep track of
session data) thusly:

Public Session As clsSession

Public Function SessionInit()

Set Session = New HDSession

End Sub

Apr 14 '07 #1
7 1907
robert.waters wrote:
Why do my public variables (including class instances) disappear when
my app experiences an unhandled error?

My custom class module's class_terminate event doesn't even fire, the
instance just goes out of scope/gets garbage collected/disappears into
thin air.

Does anyone know why Access behaves in this manner, or more
importantly how to change that behavior?

FYI I am using an AutoExec macro to call a public function (in a
module) that creates an instance of a custom class (to keep track of
session data) thusly:

Public Session As clsSession

Public Function SessionInit()

Set Session = New HDSession

End Sub
It's always been that way. MDE's don't do this however.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Apr 14 '07 #2
On Apr 14, 1:09 pm, "Rick Brandt" <rickbran...@hotmail.comwrote:
robert.waters wrote:
Why do my public variables (including class instances) disappear when
my app experiences an unhandled error?
My custom class module's class_terminate event doesn't even fire, the
instance just goes out of scope/gets garbage collected/disappears into
thin air.
Does anyone know why Access behaves in this manner, or more
importantly how to change that behavior?
FYI I am using an AutoExec macro to call a public function (in a
module) that creates an instance of a custom class (to keep track of
session data) thusly:
Public Session As clsSession
Public Function SessionInit()
Set Session = New HDSession
End Sub

It's always been that way. MDE's don't do this however.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Thank you Rick.
So, the only viable option for saving session data is with a hidden
form? Not a tasty hack...

Apr 14 '07 #3
robert.waters wrote:
On Apr 14, 1:09 pm, "Rick Brandt" <rickbran...@hotmail.comwrote:
robert.waters wrote:
Why do my public variables (including class instances) disappear
when my app experiences an unhandled error?
My custom class module's class_terminate event doesn't even fire,
the instance just goes out of scope/gets garbage
collected/disappears into thin air.
Does anyone know why Access behaves in this manner, or more
importantly how to change that behavior?
FYI I am using an AutoExec macro to call a public function (in a
module) that creates an instance of a custom class (to keep track
of session data) thusly:
Public Session As clsSession
Public Function SessionInit()
Set Session = New HDSession
End Sub
It's always been that way. MDE's don't do this however.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Thank you Rick.
So, the only viable option for saving session data is with a hidden
form? Not a tasty hack...
Or use an MDE
Or use classes (don't think they have this issue)
Or handle all errors

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Apr 14 '07 #4
On Apr 14, 2:05 pm, "Rick Brandt" <rickbran...@hotmail.comwrote:
robert.waters wrote:
On Apr 14, 1:09 pm, "Rick Brandt" <rickbran...@hotmail.comwrote:
robert.waters wrote:
Why do my public variables (including class instances) disappear
when my app experiences an unhandled error?
My custom class module's class_terminate event doesn't even fire,
the instance just goes out of scope/gets garbage
collected/disappears into thin air.
Does anyone know why Access behaves in this manner, or more
importantly how to change that behavior?
FYI I am using an AutoExec macro to call a public function (in a
module) that creates an instance of a custom class (to keep track
of session data) thusly:
Public Session As clsSession
Public Function SessionInit()
Set Session = New HDSession
End Sub
It's always been that way. MDE's don't do this however.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Thank you Rick.
So, the only viable option for saving session data is with a hidden
form? Not a tasty hack...

Or use an MDE
Or use classes (don't think they have this issue)
Or handle all errors

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
FYI a class module exhibited that behavior as well.
Thanks for your help.

Apr 14 '07 #5
"robert.waters" <ro***********@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
Why do my public variables (including class instances) disappear when
my app experiences an unhandled error?
VB always been that way.

the simple solution is to either have error handling in your code. And, as
others mentioned, if serious about using ms-access, then you need to deploy
using a mde.

However, if you deploy a mde then you can't make changes to the resulting
designs, and thus, it follows that you split your database.

So, really, the issue here is that you need to put on a "developers" cap,
and
split your database. Splitting will allow you to deploy a mde, and then
continue
working on the next "great" release of your software (the mdb part).

I explain this concept and process here:

http://www.members.shaw.ca/AlbertKal...plit/index.htm

Once you "grasp" the development process in ms-access, then your find the
re-set
of varialbes problem goes away....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Apr 14 '07 #6
On Apr 14, 4:21 pm, "Albert D. Kallal" <PleaseNOOOsPAMmkal...@msn.com>
wrote:
"robert.waters" <robert.wat...@gmail.comwrote in message

news:11**********************@q75g2000hsh.googlegr oups.com...
Why do my public variables (including class instances) disappear when
my app experiences an unhandled error?

VB always been that way.

the simple solution is to either have error handling in your code. And, as
others mentioned, if serious about using ms-access, then you need to deploy
using a mde.

However, if you deploy a mde then you can't make changes to the resulting
designs, and thus, it follows that you split your database.

So, really, the issue here is that you need to put on a "developers" cap,
and
split your database. Splitting will allow you to deploy a mde, and then
continue
working on the next "great" release of your software (the mdb part).

I explain this concept and process here:

http://www.members.shaw.ca/AlbertKal...plit/index.htm

Once you "grasp" the development process in ms-access, then your find the
re-set
of varialbes problem goes away....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKal...@msn.com
Thanks Albert; I have a split database (SQL server + .mdb). My error
handling is fine, thanks; this issue arose while trying to .Raise an
error in test.
Please forgive me for being surprised when my objects disappeared
without so much as a whisper from their deconstructor; surely it must
be that Visual Basic is beyond my "grasp".
As for my developer's cap, well it's old, worn, and tattered but it
fits me perfectly.
I do appreciate your comments (though unnecessarily condescending).
Apr 14 '07 #7
robert.waters wrote:
>
FYI a class module exhibited that behavior as well.
Thanks for your help.
Perhaps the instance of the class was saved in a reference variable in a module and that
is why the class did this.

Why not use tables to store your values?

Error handling should prevent this issue. I've used code to re-instantiate the class if I
find I don't have a reference to it but might not be a viable answer for your project.

I've used the hidden form method as well; a side benefit of immediately opening a hidden
form is that it is guaranteed to be the last form closed (LIFO) and so you can put code in
the Unload event to run whenever the application is closed and doing any necessary cleanup.

--
---------------
John Mishefske, Microsoft Access MVP
Apr 15 '07 #8

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

Similar topics

2
by: R. Rajesh Jeba Anbiah | last post by:
I'm interested to know which one is better--define or global variables especially for config stuffs. For example, osCommerce use something like: define('db_user', 'xx'); whereas phpMyAdmin uses...
1
by: Rafael | last post by:
Hi, I hope I can find some help for this problem IDE: Visual Studio.NET 2003 Developer Editio Language: C# Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in...
5
by: terry | last post by:
Hi, Question: When using Framesets and Server.Transfer in the Application_Error event handler is there a mechanism to get the error page to display in the total view of the browser not just in...
3
by: thdevdex | last post by:
I'm new to the web forms world (ASP.Net) but not vb and am converting a vb6 windows app to the web. If I create public subroutines at a module level, is this a problem in a server based app? Will...
4
by: Frank | last post by:
Hi, I made a handler for unhandled errors. But before that is executed, VB.NET gives me the standard error window. In VB6 there was a setting (errortrapping) about handling errors in the design...
4
by: Dennis | last post by:
I have read and re-read VB.Net's help on scope of variables but darned if I can understand the difference between Friend and Public variables? -- Dennis in Houston
9
by: Rudy | last post by:
Hello All! I'm a little confused on Public Class or Modules. Say I have a this on form "A" Public Sub Subtract() Dim Invoice As Decimal Dim Wage As Decimal Static PO As Decimal Invoice =...
1
by: bg_ie | last post by:
Hi, I have the following Program.cs - namespace TestFrameworkApplication { static class Program { /// <summary> /// The main entry point for the application.
9
by: ARC | last post by:
Hello all, I've noticed some funny things in my 2007 app lately, particularly where it's not putting up errors when I know a field doesn't exist, etc. In the VBA window, under Tools, Options,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.