473,722 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1860
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
programaticall y 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.Prope rties("MyProper ty") = 12345

Read the property.
MyVariable = CurrentDb.Prope rties!MyPropert y


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*******@gmai l.comwrote in message
news:cd******** *************** ***********@d21 g2000prf.google groups.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...@stantonfa mily.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...@gmai l.comwrote in message

news:cd******** *************** ***********@d21 g2000prf.google groups.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...@NOhotm ailSPAM.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.Prope rties("MyProper ty") = 12345

Read the property.
MyVariable = CurrentDb.Prope rties!MyPropert y

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...@stantonfa mily.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...@gm ail.comwrote in message

news:cd****** *************** *************@d 21g2000prf.goog legroups.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
applicatio n 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
programatica lly 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.c omwrote:
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=Lf5c2xf eAMk
I appreciate your contribution though!
TX
On Feb 4, 5:19 pm, "Phil Stanton" <p...@stantonfa mily.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...@gma il.comwrote in message
>news:cd******* *************** ************@d2 1g2000prf.googl egroups.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
programatical ly 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...@stantonfa mily.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...@gmai l.comwrote in message

news:e2******** *************** ***********@c23 g2000hsa.google groups.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...@stantonfa mily.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...@gmai l.comwrote in message
>news:cd******* *************** ************@d2 1g2000prf.googl egroups.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

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

Similar topics

2
2663
by: Martin Magnusson | last post by:
It seems that the following code is not valid, but I need to find a workaround. Both gcc and Comeau tells me that j can't be used as a template argument, even though it's declared as a const unsigned. Is there a way to get around this? template< unsigned M > class Tree { public: Tree()
188
17377
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
2
2946
by: Cosmin Prund | last post by:
This is supposed to be very easy, only I did not find this in MSDN so I'll ask here: How do I enter a char constant using the char's ASCII number? Specifically I want to be able to compare a char to one of CR, LF, TAB (i.e: char number 13, 10, 9). I suppose there's a problem because c#'s char's are unicode and I'm talking ascii codes, but there must be a way to do it!
48
4742
by: mahurshi | last post by:
I am new to c++ classes. I defined this "cDie" class that would return a value between 1 and 6 (inclusive) It runs fine and gives no warnings during compilation. I was wondering if you guys can pick up any mistakes/"don't do"s from this code: #include <iostream> #include <cstdlib>
43
2728
by: markryde | last post by:
Hello, I saw in some open source projects a use of "!!" in "C" code; for example: in some header file #define event_pending(v) \ (!!(v)->vcpu_info->evtchn_upcall_pending & \ !(v)->vcpu_info->evtchn_upcall_mask) whereas evtchn_upcall_pending is of type unsigned char (and also evtchn_upcall_mask is of type unsigned char).
0
2181
by: Carl Gilbert | last post by:
Hi I am trying to use a custom attribute that takes in an array or list of custom objects. Ths custom object has a text property and a type property. I have a custom attribute which has a constructor that takes a class as follows: ======================================================= Public Class MyAttribute Inherits System.Attribute
25
2575
by: tsaar2003 | last post by:
Hi Pythonians, To begin with I'd like to apologize that I am not very experienced Python programmer so please forgive me if the following text does not make any sense. I have been missing constants in Python language. There are some workarounds available, for example the const-module. To me, this looks quite cumbersome and very unintuitive. For the interpreter, in the efficiency-wise, I just cannot tell.
1
6500
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
4
3080
by: jaime | last post by:
Hi again all. Given the line: const int x=5; Can I then use "x" as a constant expression? (By "constant expression", I mean "constant expression" as defined in the C99 standard) I've been searching google for 2 days now trying to answer this myself, and I'm just getting more and more confused (some things I read make me think "yes", while some things I read make me think "no").
0
8739
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9383
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9236
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9154
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8051
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5995
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2601
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.