Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the value of constants in code

Status
Not open for further replies.

cascot

Programmer
Jan 30, 2002
127
CA
If I have a set of constants named, say,

iConst_1
iConst_2
.
.
iConst_99

Is there a way within code of being able to refer to the values stored by these constants without having to explicitely name each one. Something like...

i = 1
Do until i >99
anArray(i - 1) = "iConst_" & i
i = i + 1
Loop

Obviously the above would simply set the array to contain the string "iConst_1", etc, but is there any similar mechanism for getting the actual value stored by the constant?
 
If you ahve that many constants you're probably way better off storing them in a table. They'll be easy to retrieve in whatever way you want, and you'll be able to store a bit of data in another field to tell you what the heck each one is.

What are you doing with so many constants?

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
It's to do with storing security codes for product activation along with related dates.

I was going to put the information in a table, which I would encrypt, as well as it being in a MDE with shift-key access, etc disabled, but the powers that be wanted it done in code only.
 
Cool. Sounds reasonable. I don't know why I didn't write this in my last post, but have you played with the Eval function? It might work to wrap that around your expression, como este:
anArray(i - 1) = eval("iConst_" & i)

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top