473,327 Members | 2,012 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,327 software developers and data experts.

Public variables reset on error, what's up?

Hello,

I have an interface that sets some variables when it starts up. For some
reason, when I have an error in the code (wherever it is, even if it isn't
related to the variables) the variables reset to zero and 12:00 am for the
date field that I'm setting. Any ideas?

Thanks!
Nov 13 '05 #1
7 2396

"Jozef" <me@you.com> wrote in message news:oXoYe.246497$Hk.54820@pd7tw1no...
Hello,

I have an interface that sets some variables when it starts up. For some
reason, when I have an error in the code (wherever it is, even if it isn't
related to the variables) the variables reset to zero and 12:00 am for the
date field that I'm setting. Any ideas?

Thanks!


That's normal behavior. You need to trap and handle the errors if you wish
to prevent it from happening.

Nov 13 '05 #2
I'll have to keep an eye on it, but most of the errors that I can think of
are trapped and handled. Maybe not handled correctly? Normally when I
handle errors I just state something like the following;

Function Whatever()
On Error goto Whatever_Error

[Whatever code here]

Whatever_Exit:
Exit Function

Whatever_Err:

msgbox err.description
resume whatever_Exit

End Function

Would an error thrown in this circumstance still reset the variables?

Thanks!
"Randy Harris" <ra***@SpamFree.com> wrote in message
news:Ec***************@newssvr24.news.prodigy.net. ..

"Jozef" <me@you.com> wrote in message
news:oXoYe.246497$Hk.54820@pd7tw1no...
Hello,

I have an interface that sets some variables when it starts up. For some
reason, when I have an error in the code (wherever it is, even if it
isn't
related to the variables) the variables reset to zero and 12:00 am for
the
date field that I'm setting. Any ideas?

Thanks!


That's normal behavior. You need to trap and handle the errors if you
wish
to prevent it from happening.

Nov 13 '05 #3
On Thu, 22 Sep 2005 02:47:48 GMT, "Jozef" <me@you.com> wrote:
Hello,

I have an interface that sets some variables when it starts up. For some
reason, when I have an error in the code (wherever it is, even if it isn't
related to the variables) the variables reset to zero and 12:00 am for the
date field that I'm setting. Any ideas?

Thanks!

Hi
To avoid this I put such variables into controls on an invisible form.

Nov 13 '05 #4

"Jozef" <me@you.com> wrote in message
news:PizYe.535954$5V4.362686@pd7tw3no...
I'll have to keep an eye on it, but most of the errors that I can think of
are trapped and handled. Maybe not handled correctly? Normally when I
handle errors I just state something like the following;

Function Whatever()
On Error goto Whatever_Error

[Whatever code here]

Whatever_Exit:
Exit Function

Whatever_Err:

msgbox err.description
resume whatever_Exit

End Function

Would an error thrown in this circumstance still reset the variables?

Thanks!


No, in that function the errors are handled. That should keep it from
happening. I haven't seen the behavior you described (public variables
reset) except from unhandled errors.

Nov 13 '05 #5
Randy Harris wrote:
No, in that function the errors are handled. That should keep it from
happening. I haven't seen the behavior you described (public variables
reset) except from unhandled errors.


Also this doesn't occur in MDE files so if that is what you distribute to
users it might be a non-issue.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #6
ALL variables include local, and even non public variables are re-set when
you encounter a error.

So, it is NOT just a global problem, but even the local vars in the current
routine will get re-set.

There are several solutions:

1) Place error handing code in any routine
2) use a mde.

You should be deploying a mde file to your users anyway. The added bonus of
a mde is that un-handled errors don't re-set the variables. This is only
one of many reasons why a mde file is going to be much more reliable then a
mdb file. Of course, to use a mde file, then you really have to split your
database. You can read about that here:

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

So, since mde's don't re-vars, I always distribute them to my users....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #7
Good deal, I am distributing an mde. *Phew!*

Thanks!

"Albert D. Kallal" <ka****@msn.com> wrote in message
news:T0EYe.247991$Hk.34460@pd7tw1no...
ALL variables include local, and even non public variables are re-set when
you encounter a error.

So, it is NOT just a global problem, but even the local vars in the
current routine will get re-set.

There are several solutions:

1) Place error handing code in any routine
2) use a mde.

You should be deploying a mde file to your users anyway. The added bonus
of a mde is that un-handled errors don't re-set the variables. This is
only one of many reasons why a mde file is going to be much more reliable
then a mdb file. Of course, to use a mde file, then you really have to
split your database. You can read about that here:

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

So, since mde's don't re-vars, I always distribute them to my users....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal

Nov 13 '05 #8

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

Similar topics

2
by: Jose Meireles | last post by:
Hi everyone, I'm trying to use public variables in a web form to hld specific values. What happens is that the public variables (declared as public x as y in the beginning of the class), doesn't...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
13
by: Sunil | last post by:
Hi all, I want to know how good or bad it is using global variables i.e advantages and disadvantages of using global variables. Sunil.
1
by: Steve Remer | last post by:
My application (relevant code snippets below) originally used Session variables in order to maintain state from page to page. After being unable to solve the mystery of why those variables were...
3
by: pauldepstein | last post by:
Sorry in advance if this message sounds imprecise but it's difficult to be precise when you don't really understand what's going on. I have a class called Parameters. The default constructor...
7
by: Kermit Piper | last post by:
Hello, How can you clear session variables when a reset button is pressed? I thought I might be able to do something like: <% If request.form("Reset") = "Reset" then Session("variable") =...
1
by: stephane | last post by:
I have a problem which must be in this : print" <script type='text/javascript'> document.location.replace('http://127.0.0.1/add_task.php?req_id={$maxValue}&tk_request_name={$req_name}');...
9
by: Rory Campbell-Lange | last post by:
We have a set of classes using static methods to retain reference variables between operations. The problem is that the static variables are not reset between operations when used through...
11
by: Web Search Store | last post by:
Hello, I set up a web page with 2 user controls. In classic asp, the first one did all the declarations, and the second one used the values, and could reset it. In ASP.Net so far I can't...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
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...
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.