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

Global Variables Reset on Error

P: 2
Hello All,

I have an issue with an Access 2003 ADP file hooking up to SQL Server 2005.

I had a global variable in a module like the following:

Public loginUserName As String

I found out that upon errors, the value for this variable gets reset. So, after some initial online research, I changed this variable to a property in a code module:

Public Property Let UserID(strUID As String)
mstrUID = strUID
End Property

Public Property Get UserID() As String
UserID = mstrUID
End Property

That seemed to work initially when combined with a generic error handler that is used to log all errors.

I've just recently been notified by the Client that the value from "UserID" is still getting flushed out -- but mainly on "timeout expired" errors.

Is there a way (with fewer resources used as possible) to maintain these "global" values upon errors/timeouts?

Thanks!!
Dec 3 '08 #1
Share this Question
Share on Google+
3 Replies


FishVal
Expert 2.5K+
P: 2,653
Hello, Xanfere.

To the best of my knowledge, when error has been handled and cleared via some kind of Resume statement, global variable are not destroyed.

Regards,
Fish.
Dec 3 '08 #2

P: 2
I did a workaround...

Upon successfully logging into the app, I write the values to a text file (in the same folder as the .adp file). Then, if any of these values are blank when I access it, I just read in the values from the text file and refresh the custom properties.

So far, it seems to work fine...
Dec 3 '08 #3

Expert 100+
P: 1,287
You could also store the values not visible on a form or on a hidden form, or just call the function to get the user name anew any time you need it and it's blank, rather than use the text file.
Dec 3 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.