Rabu, 08 Mei 2013

RE: [MS_AccessPros] Re: disappearing global variables

 

Bill-

Yes, I use that technique, too. I write a "wrapper" function to fetch
globals, like this:

Public Function GetUser() As String
' If the Public variable not initialized
If Len(GStrUser) = 0 Then
' Grab it from the table
GStrUser = DLookup("User", "ztblGlobals")
End If
' Return the value
GetUser = GStrUser
End Function

Anytime the Public variable isn't set, the code fetches it. If set, it just
returns it.

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Bill Mosca
Sent: Wednesday, May 08, 2013 5:29 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Re: disappearing global variables

Onno

In addition to what John said, when I use globals in a development
environment I test them when moving from one object to another just to make
sure they are still okay. But because all my production applications are
MDEs with error traps in every procedure, the globals do not reset and are
very stable.

A table of values is a good idea and probably isn't that much slower than a
global variable. You would just have to make sure to clear the table when
the application first opens so you don't have the wrong values stored.

Regards,
Bill Mosca, Founder - MS_Access_Professionals http://www.thatlldoit.com
Microsoft Office Access MVP
https://mvp.support.microsoft.com/profile=C4D9F5E7-BB03-4291-B816-6427073088
1E
My nothing-to-do-with-Access blog
http://wrmosca.wordpress.com

--- In MS_Access_Professionals@yahoogroups.com, "Onno Knol" <onno.knol@...>
wrote:
>
> Dear Friends,
>
> In my MsAccess application I define a number of global variables, like
paths where I want to store files.
> Now it sometimes happens that these gobal variables disappear somewhere in
the process of working with the application. Then my files suddenly are
stored on unexpected places like the root directory. What can be the cause?
A memory leak? And more important, how can I trace where this happens? Until
now it seems like a random phenomenon.
>
> Has anyone ever had this problem and how did you handle it? One
alternative is to stop using global variables and read-write them to a
database table called settings,but I think this will be slower.
>
> Any thoughts would help.
>
> Thanks, Onno Knol
>

------------------------------------

Yahoo! Groups Links

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar