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

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("gstrFileServer"):? GetValue("gstrDataServer")
\\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 8188
Gordon,
You could create a function like:

Function GetgstrValue (strWantedValue as String) as String
If strWantedValue ="gstrFileServer" Then GetstrValue = gstrFileServer
If strWantedValue ="gstrDataServer " 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.com> schreef in bericht
news:a9**************************@posting.google.c om...
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("gstrFileServer"):? GetValue("gstrDataServer")
\\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("gstrFileServer"):? GetValue("gstrDataServer")
\\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 ="gstrFileServer" Then GetstrValue = gstrFileServer
If strWantedValue ="gstrDataServer " 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("gstrFileServer") As Value...

Any other ideas?
Nov 12 '05 #4
> > ? GetValue("gstrFileServer"):? GetValue("gstrDataServer")
\\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("gstrFileServer") 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 ="gstrFileServer" Then
GetstrValue = gstrFileServer
ElseIf strWantedValue ="gstrDataServer " 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.com> schreef in bericht
news:a9**************************@posting.google.c om...
You could create a function like:

Function GetgstrValue (strWantedValue as String) as String
If strWantedValue ="gstrFileServer" Then GetstrValue = gstrFileServer
If strWantedValue ="gstrDataServer " 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("gstrFileServer") As Value...

Any other ideas?



Nov 12 '05 #6
On 2 Sep 2003 14:05:36 -0700 in comp.databases.ms-access,
ro*****@mico.com (Salvani Langosta) wrote:
> ? GetValue("gstrFileServer"):? GetValue("gstrDataServer")
> \\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("gstrFileServer") 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
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...
2
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()...
15
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...
8
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...
3
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...
49
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...
20
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 =...
6
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...
20
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.