473,545 Members | 4,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieve Value Of Global Variables

In an Access 97 database, I use serveral global variables that hold
information about the database, for example:

gstrFileServer - holds the server root where the database is stored
gstrDataServer - holds the server root where a related data warehouse
is stored

The values of these variables are set when the database is opened.

I want to retrieve one or more of these values in a query, but Access
does not recognize variables in a query. The alternative is to
include a function call in the query that returns the value of a
variable.

I want to write one function that accepts a string value identifying
the variable, then returns the value of the given variable.

Calling the function from the debug window might produce the
following:

? GetValue("gstrF ileServer"):? GetValue("gstrD ataServer")
\\FILE_001\VOL_ 0001
\\DATA_009\VOL_ 0002

What is the function that will extract the value from a given
variable?

Thanks in advance,

Gordon Rogers
MICO, Inc.
Nov 12 '05 #1
6 8197
Gordon,
You could create a function like:

Function GetgstrValue (strWantedValue as String) as String
If strWantedValue ="gstrFileServe r" Then GetstrValue = gstrFileServer
If strWantedValue ="gstrDataServe r " Then GetstrValue = gstrDataServer
End function

Be aware of the fact that global vars loose their values after untrapped runtime errors.
In a runtime Access environment this is no problem (Access crashes... and has to be restarted)
In a full Access environment I have seen unpredictable result swith this.

You could also store the values in a table and create a function to Lookup when needed.

--
Hope this helps
Arno R

"Salvani Langosta" <ro*****@mico.c om> schreef in bericht
news:a9******** *************** ***@posting.goo gle.com...
In an Access 97 database, I use serveral global variables that hold
information about the database, for example:

gstrFileServer - holds the server root where the database is stored
gstrDataServer - holds the server root where a related data warehouse
is stored

The values of these variables are set when the database is opened.

I want to retrieve one or more of these values in a query, but Access
does not recognize variables in a query. The alternative is to
include a function call in the query that returns the value of a
variable.

I want to write one function that accepts a string value identifying
the variable, then returns the value of the given variable.

Calling the function from the debug window might produce the
following:

? GetValue("gstrF ileServer"):? GetValue("gstrD ataServer")
\\FILE_001\VOL_ 0001
\\DATA_009\VOL_ 0002

What is the function that will extract the value from a given
variable?

Thanks in advance,

Gordon Rogers
MICO, Inc.

Nov 12 '05 #2
Salvani Langosta wrote:
? GetValue("gstrF ileServer"):? GetValue("gstrD ataServer")
\\FILE_001\VOL_ 0001
\\DATA_009\VOL_ 0002

What is the function that will extract the value from a given
variable?


Have you tried something like:

Function fDataServer as string

fDataServer = gstrFileServer

end function

--
Tim - http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Want some?" - Ditto
Nov 12 '05 #3
> You could create a function like:

Function GetgstrValue (strWantedValue as String) as String
If strWantedValue ="gstrFileServe r" Then GetstrValue = gstrFileServer
If strWantedValue ="gstrDataServe r " Then GetstrValue = gstrDataServer
End function


You're on the right track here, but I want to avoid using an if
statement for every variable used (there are 20+ variables) in the
application. What I want to do is provide a function that can be
called from a query, and will return the value held by the variable,
i.e.

SELECT GetValue("gstrF ileServer") As Value...

Any other ideas?
Nov 12 '05 #4
> > ? GetValue("gstrF ileServer"):? GetValue("gstrD ataServer")
\\FILE_001\VOL_ 0001
\\DATA_009\VOL_ 0002

What is the function that will extract the value from a given
variable?


Have you tried something like:

Function fDataServer as string

fDataServer = gstrFileServer

end function


Would this require a separate function for each variable? My goal is
to write one function that will return the value of any variable when
called from a query, i.e.

SELECT GetValue("gstrF ileServer") As Value...

Any other ideas?
Nov 12 '05 #5
Gordon,
I don't see a problem using more statements in the function GetstrValue.
What's the deal? Function does exactly what you want?
The function can (and must in the case of 20+ gvars) be written more efficiently but it needs more
lines then...
Function GetgstrValue (strWantedValue as String) as String
If strWantedValue ="gstrFileServe r" Then
GetstrValue = gstrFileServer
ElseIf strWantedValue ="gstrDataServe r " Then
GetstrValue = gstrDataServer
......
End if
End Function
If you don't like 'If' then use Select Case ;-)

If you use a table as I suggested you can go along with only one Lookup-function with only one line
like:
(tblGlobals as suggested by Paii)

Function GetgstrValue (strWantedValue as String) as String
GetgstrValue = dlookup("[GlobalValue]","tblGlobals", "[GlobalID]='" & strWantedValue & "'")
End function

--
Hope this helps
Arno R
"Salvani Langosta" <ro*****@mico.c om> schreef in bericht
news:a9******** *************** ***@posting.goo gle.com...
You could create a function like:

Function GetgstrValue (strWantedValue as String) as String
If strWantedValue ="gstrFileServe r" Then GetstrValue = gstrFileServer
If strWantedValue ="gstrDataServe r " Then GetstrValue = gstrDataServer
End function


You're on the right track here, but I want to avoid using an if
statement for every variable used (there are 20+ variables) in the
application. What I want to do is provide a function that can be
called from a query, and will return the value held by the variable,
i.e.

SELECT GetValue("gstrF ileServer") As Value...

Any other ideas?



Nov 12 '05 #6
On 2 Sep 2003 14:05:36 -0700 in comp.databases. ms-access,
ro*****@mico.co m (Salvani Langosta) wrote:
> ? GetValue("gstrF ileServer"):? GetValue("gstrD ataServer")
> \\FILE_001\VOL_ 0001
> \\DATA_009\VOL_ 0002
>
> What is the function that will extract the value from a given
> variable?


Have you tried something like:

Function fDataServer as string

fDataServer = gstrFileServer

end function


Would this require a separate function for each variable? My goal is
to write one function that will return the value of any variable when
called from a query, i.e.

SELECT GetValue("gstrF ileServer") As Value...

Any other ideas?


You could use GetSetting() and SaveSetting() to retrieve and store in
the registry. For intrinsic values only.

--
A)bort, R)etry, I)nfluence with large hammer.

(replace sithlord with trevor for email)
Nov 12 '05 #7

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

Similar topics

4
4217
by: Peter Kaptein | last post by:
I am building websites using Databases and COM for 3tier apps. Currently I have to tell my COM object where the database is located either 1) Hardcoded in the DLL 2) Via my ASP call How do I retrieve the dir where my DLL is located? In the VB6 runtime environment "CurDir" does it for the runtime-situation Once I go "DLL" CurDir is...
2
2883
by: evangeline | last post by:
We have ASP application running on IIS 5.1 and Windows 2000 server. The ASP application has few Application variables setup in global.asa. Something like this: Application.Lock() Application("fun")="play" Application.UnLock() There is no other code in the ASP application to change the value in the Application variables. It's only set in...
15
3200
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone tell me why these DIVs don't drift to the left as they are supposed to? <script language="javascript">
8
6778
by: Simone Chiaretta | last post by:
I've a very strange behaveour related to a website we built: from times to times, something should happen on the server, and all static variables inside the web application, both defined inside aspx code-behind and in business logic (C# classes used by the aspx) lose their value. I cannot reproduce this on our development server, so I cannot...
3
2891
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have any experience on how to keep track of session value. Any help it's appreciated. Thanks Alan
49
14438
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On http://www.webreference.com/programming/javascript/gr/column9/ they say: <snip> The undefined property A relatively recent addition to JavaScript is the undefined property.
20
6934
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt = document.getElementById('hometab'); Has anyone ever seen anything like this before, or am I dreaming?
6
1646
by: trungthanh78 | last post by:
Hello everyone, I'm totally new to the group and I would like to learn from you. Thank you in advance! I need to write a program to track whether a mathematical function has changed during run-time or not. The program should work with any mathematical function provided by users. Let's take an example in the C language:
20
12700
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The AutoExec macro calls a function "InitApplication" which, in turn, calls a function to set the value of a global string variable
0
7464
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7396
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...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
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...
0
7751
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...
0
4943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3440
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
700
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...

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.