469,594 Members | 2,175 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,594 developers. It's quick & easy.

How can I get "CONSTANT" behavior from a variable (Constant magic)?

running access 2k;
And before anything else is said - "Yes, Virginia, I know you can NOT
use a variable to set a constant (that's why it's constant)".

BUT - my problem is - I want a constant, that I can set from a
variable (one time)!!!

When my application starts, the user is prompted to make a selection
from a list.
I want that selection to go into a global variable, and NEVER CHANGE
while the application is running. This means that if the application
encounters an unexpected error - this value is NOT lost.

If the user wants to change this value, they should have to close the
application and restart.

This is the BEHAVIOR I'm looking for.....

Is this behavior possible, and if so, how?

BTW -
I should mention, that I successfully accomplished this by actually
programatically inserting a global constant statement into a "globals
module" ! (the insertion statement, of course used a variable to
define the statement). Problem is, (no surprise), this can NOT be done
in a run-time application.... ;o)

thoughts or discussion?

TIA!!
Bob
Feb 4 '08 #1
13 1668
On Mon, 4 Feb 2008 14:25:53 -0800 (PST), bo*******@gmail.com wrote:
>running access 2k;
And before anything else is said - "Yes, Virginia, I know you can NOT
use a variable to set a constant (that's why it's constant)".

BUT - my problem is - I want a constant, that I can set from a
variable (one time)!!!

When my application starts, the user is prompted to make a selection
from a list.
I want that selection to go into a global variable, and NEVER CHANGE
while the application is running. This means that if the application
encounters an unexpected error - this value is NOT lost.

If the user wants to change this value, they should have to close the
application and restart.

This is the BEHAVIOR I'm looking for.....

Is this behavior possible, and if so, how?

BTW -
I should mention, that I successfully accomplished this by actually
programatically inserting a global constant statement into a "globals
module" ! (the insertion statement, of course used a variable to
define the statement). Problem is, (no surprise), this can NOT be done
in a run-time application.... ;o)

thoughts or discussion?

TIA!!
Bob
You could create a custom property to store the value and seed it on opening the
database.

Create the property (once only)
CurrentDb = CreateProperty("MyProperty", dbLong)

Seed the property on startup.
CurrentDb.Properties("MyProperty") = 12345

Read the property.
MyVariable = CurrentDb.Properties!MyProperty


Wayne Gillespie
Gosford NSW Australia
Feb 4 '08 #2
Strikes me the simple way is to put it in a table. OK I know you need an
ELookup or DLookup to retrieve it

Phil

<bo*******@gmail.comwrote in message
news:cd**********************************@d21g2000 prf.googlegroups.com...
running access 2k;
And before anything else is said - "Yes, Virginia, I know you can NOT
use a variable to set a constant (that's why it's constant)".

BUT - my problem is - I want a constant, that I can set from a
variable (one time)!!!

When my application starts, the user is prompted to make a selection
from a list.
I want that selection to go into a global variable, and NEVER CHANGE
while the application is running. This means that if the application
encounters an unexpected error - this value is NOT lost.

If the user wants to change this value, they should have to close the
application and restart.

This is the BEHAVIOR I'm looking for.....

Is this behavior possible, and if so, how?

BTW -
I should mention, that I successfully accomplished this by actually
programatically inserting a global constant statement into a "globals
module" ! (the insertion statement, of course used a variable to
define the statement). Problem is, (no surprise), this can NOT be done
in a run-time application.... ;o)

thoughts or discussion?

TIA!!
Bob

Feb 4 '08 #3
bo*******@gmail.com wrote:
running access 2k;
And before anything else is said - "Yes, Virginia, I know you can NOT
use a variable to set a constant (that's why it's constant)".

BUT - my problem is - I want a constant, that I can set from a
variable (one time)!!!

When my application starts, the user is prompted to make a selection
from a list.
I want that selection to go into a global variable, and NEVER CHANGE
while the application is running. This means that if the application
encounters an unexpected error - this value is NOT lost.

If the user wants to change this value, they should have to close the
application and restart.

This is the BEHAVIOR I'm looking for.....

Is this behavior possible, and if so, how?

BTW -
I should mention, that I successfully accomplished this by actually
programatically inserting a global constant statement into a "globals
module" ! (the insertion statement, of course used a variable to
define the statement). Problem is, (no surprise), this can NOT be done
in a run-time application.... ;o)

thoughts or discussion?

TIA!!
Bob
Why not store the value in a table? You could have 1 or more fields
that might change on a daily, weekly, monthly, yearly time period.
Create the fields you want. Add 1 record to the table. Plug in some
values as needed. Then update that one record to your hearts content.

WorkIt
http://www.youtube.com/watch?v=KEuLlqDQDAw
Feb 4 '08 #4
Hi Phil;

Tx, for your reply!

yea; I should have mentioned, that I did think of using a table. But I
run from doing this, because the *lookup's are SO costly (performance-
wise).

I appreciate your contribution though!
TX

On Feb 4, 5:19 pm, "Phil Stanton" <p...@stantonfamily.co.ukwrote:
Strikes me the simple way is to put it in a table. OK I know you need an
ELookup or DLookup to retrieve it

Phil

<bobg.h...@gmail.comwrote in message

news:cd**********************************@d21g2000 prf.googlegroups.com...
running access 2k;
And before anything else is said - "Yes, Virginia, I know you can NOT
use a variable to set a constant (that's why it's constant)".
BUT - my problem is - I want a constant, that I can set from a
variable (one time)!!!
When my application starts, the user is prompted to make a selection
from a list.
I want that selection to go into a global variable, and NEVER CHANGE
while the application is running. This means that if the application
encounters an unexpected error - this value is NOT lost.
If the user wants to change this value, they should have to close the
application and restart.
This is the BEHAVIOR I'm looking for.....
Is this behavior possible, and if so, how?
BTW -
I should mention, that I successfully accomplished this by actually
programatically inserting a global constant statement into a "globals
module" ! (the insertion statement, of course used a variable to
define the statement). Problem is, (no surprise), this can NOT be done
in a run-time application.... ;o)
thoughts or discussion?
TIA!!
Bob
Feb 5 '08 #5
On Feb 4, 5:16 pm, Wayne Gillespie <best...@NOhotmailSPAM.com.au>
wrote:
On Mon, 4 Feb 2008 14:25:53 -0800 (PST), bobg.h...@gmail.com wrote:
running access 2k;
And before anything else is said - "Yes, Virginia, I know you can NOT
use a variable to set a constant (that's why it's constant)".
BUT - my problem is - I want a constant, that I can set from a
variable (one time)!!!
When my application starts, the user is prompted to make a selection
from a list.
I want that selection to go into a global variable, and NEVER CHANGE
while the application is running. This means that if the application
encounters an unexpected error - this value is NOT lost.
If the user wants to change this value, they should have to close the
application and restart.
This is the BEHAVIOR I'm looking for.....
Is this behavior possible, and if so, how?
BTW -
I should mention, that I successfully accomplished this by actually
programatically inserting a global constant statement into a "globals
module" ! (the insertion statement, of course used a variable to
define the statement). Problem is, (no surprise), this can NOT be done
in a run-time application.... ;o)
thoughts or discussion?
TIA!!
Bob

You could create a custom property to store the value and seed it on opening the
database.

Create the property (once only)
CurrentDb = CreateProperty("MyProperty", dbLong)

Seed the property on startup.
CurrentDb.Properties("MyProperty") = 12345

Read the property.
MyVariable = CurrentDb.Properties!MyProperty

Wayne Gillespie
Gosford NSW Australia

Cheers, Wayne!

Tx for your input.... that is an interesting idea...
I already do that to report the app's version...

Not sure which is better - hidden form approach, or custom property...
But both do sound pretty good, and either should be a solution!
TX
Feb 5 '08 #6
bo*******@gmail.com wrote:
Hi Phil;

Tx, for your reply!

yea; I should have mentioned, that I did think of using a table. But I
run from doing this, because the *lookup's are SO costly (performance-
wise).
Really? For what you want? A single lookup will bring your system to
turtle DSL and not Comcast fast?
Adventure
http://www.youtube.com/watch?v=Lf5c2xfeAMk
>
I appreciate your contribution though!
TX

On Feb 4, 5:19 pm, "Phil Stanton" <p...@stantonfamily.co.ukwrote:
>>Strikes me the simple way is to put it in a table. OK I know you need an
ELookup or DLookup to retrieve it

Phil

<bobg.h...@gmail.comwrote in message

news:cd**********************************@d21g20 00prf.googlegroups.com...

>>>running access 2k;
And before anything else is said - "Yes, Virginia, I know you can NOT
use a variable to set a constant (that's why it's constant)".
>>>BUT - my problem is - I want a constant, that I can set from a
variable (one time)!!!
>>>When my application starts, the user is prompted to make a selection
from a list.
I want that selection to go into a global variable, and NEVER CHANGE
while the application is running. This means that if the application
encounters an unexpected error - this value is NOT lost.
>>>If the user wants to change this value, they should have to close the
application and restart.
>>>This is the BEHAVIOR I'm looking for.....
>>>Is this behavior possible, and if so, how?
>>>BTW -
I should mention, that I successfully accomplished this by actually
programatically inserting a global constant statement into a "globals
module" ! (the insertion statement, of course used a variable to
define the statement). Problem is, (no surprise), this can NOT be done
in a run-time application.... ;o)
>>>thoughts or discussion?
>>>TIA!!
Bob

Feb 5 '08 #7
LOL;

well OK - you got me... it's really more of my personal programming
"best practices" ..... ;-_)
On Feb 5, 4:25 pm, Salad <o...@vinegar.comwrote:
bobg.h...@gmail.com wrote:
Hi Phil;
Tx, for your reply!
yea; I should have mentioned, that I did think of using a table. But I
run from doing this, because the *lookup's are SO costly (performance-
wise).

Really? For what you want? A single lookup will bring your system to
turtle DSL and not Comcast fast?

Adventurehttp://www.youtube.com/watch?v=Lf5c2xfeAMk
I appreciate your contribution though!
TX
On Feb 4, 5:19 pm, "Phil Stanton" <p...@stantonfamily.co.ukwrote:
>Strikes me the simple way is to put it in a table. OK I know you need an
ELookup or DLookup to retrieve it
>Phil
><bobg.h...@gmail.comwrote in message
>news:cd**********************************@d21g200 0prf.googlegroups.com...
>>running access 2k;
And before anything else is said - "Yes, Virginia, I know you can NOT
use a variable to set a constant (that's why it's constant)".
>>BUT - my problem is - I want a constant, that I can set from a
variable (one time)!!!
>>When my application starts, the user is prompted to make a selection
from a list.
I want that selection to go into a global variable, and NEVER CHANGE
while the application is running. This means that if the application
encounters an unexpected error - this value is NOT lost.
>>If the user wants to change this value, they should have to close the
application and restart.
>>This is the BEHAVIOR I'm looking for.....
>>Is this behavior possible, and if so, how?
>>BTW -
I should mention, that I successfully accomplished this by actually
programatically inserting a global constant statement into a "globals
module" ! (the insertion statement, of course used a variable to
define the statement). Problem is, (no surprise), this can NOT be done
in a run-time application.... ;o)
>>thoughts or discussion?
>>TIA!!
Bob
Feb 5 '08 #8
ADO Recordset object and save the recordset to file as XML?

The Frog
Feb 6 '08 #9
Phil-
wow - TX, these are great to know about!

Bob

On Feb 5, 5:04 pm, "Phil Stanton" <p...@stantonfamily.co.ukwrote:
There are a load of "E" Functions" Work just as the "D" Functions but no
cost

Here they are
[functions snipped]
>
<bobg.h...@gmail.comwrote in message

news:e2**********************************@c23g2000 hsa.googlegroups.com...
Hi Phil;
Tx, for your reply!
yea; I should have mentioned, that I did think of using a table. But I
run from doing this, because the *lookup's are SO costly (performance-
wise).
I appreciate your contribution though!
TX
On Feb 4, 5:19 pm, "Phil Stanton" <p...@stantonfamily.co.ukwrote:
Strikes me the simple way is to put it in a table. OK I know you need an
ELookup or DLookup to retrieve it
Phil
<bobg.h...@gmail.comwrote in message
>news:cd**********************************@d21g200 0prf.googlegroups.com...
running access 2k;
And before anything else is said - "Yes, Virginia, I know you can NOT
use a variable to set a constant (that's why it's constant)".
BUT - my problem is - I want a constant, that I can set from a
variable (one time)!!!
When my application starts, the user is prompted to make a selection
from a list.
I want that selection to go into a global variable, and NEVER CHANGE
while the application is running. This means that if the application
encounters an unexpected error - this value is NOT lost.
If the user wants to change this value, they should have to close the
application and restart.
This is the BEHAVIOR I'm looking for.....
Is this behavior possible, and if so, how?
BTW -
I should mention, that I successfully accomplished this by actually
programatically inserting a global constant statement into a "globals
module" ! (the insertion statement, of course used a variable to
define the statement). Problem is, (no surprise), this can NOT be done
in a run-time application.... ;o)
thoughts or discussion?
TIA!!
Bob
Feb 6 '08 #10
that's an interesting idea...

I'm not sure it would be faster on the performance meter or not....
but certainly a path I hadn't considered....

On Feb 6, 2:19 am, The Frog <Mr.Frog.to....@googlemail.comwrote:
ADO Recordset object and save the recordset to file as XML?

The Frog
Feb 6 '08 #11
I dont know about the speed either, however you could use a splash
screen at the start of the program and just load it then - it gives
the appearance of speed because users are expecting to wait a little
at the beginning. Once it is in memory it really depends on the speed
of the computer, suffice to say its normally pretty quick these
days. :-)

Cheers

The Frog
Feb 7 '08 #12
"Albert D. Kallal" <Pl*******************@msn.comwrote:
>Another possible suggestion is to store the value in a text box of a form
that you hide (make not visible). then in place of a variable, you can use
everywhere your code:

forms!MyValuesForm!MyGlobalVar1
I use this concept *all* the time for my GlobalOptions table. And for your one
variable I'd do the same thing.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Feb 8 '08 #13
On Feb 7, 6:13 pm, "Tony Toews [MVP]" <tto...@telusplanet.netwrote:
"Albert D. Kallal" <PleaseNOOOsPAMmkal...@msn.comwrote:
Another possible suggestion is to store the value in a text box of a form
that you hide (make not visible). then in place of a variable, you can use
everywhere your code:
forms!MyValuesForm!MyGlobalVar1

I use this concept *all* the time for my GlobalOptions table. And for your one
variable I'd do the same thing.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems athttp://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog -http://msmvps.com/blogs/access/
Excellent to know -
TX much Tony...

appreciate your input.
Bob
Feb 15 '08 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Martin Magnusson | last post: by
188 posts views Thread by infobahn | last post: by
48 posts views Thread by mahurshi | last post: by
43 posts views Thread by markryde | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.