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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Variables.... 1

Status
Not open for further replies.

jeffmoore

Programmer
Aug 29, 2003
301
US
I have a form with 120 text boxes that are to me filled with values via vba.
The text boxes are numbered in blocks of 10.
ie 600 -> 610 , 611 -> 620, etc
I'm going to step thru a loop and asign the vars a value.
Q:
I'm trying to constuct a variable, variable name. like;

Text & Y & X = myvalue

where Y is the hundreds place
and X is the tens and ones.

Is this possible?
TIA
Jeff

 
Well, Y = myvalue\100
or
Int(myvalue/100)

X would be myvalue\10
or
Int(myvalue/10)

You could use

Text = Text & Y = myvalue\100 & myvalue\10

Paul

 
Opps, get rid of Y =
It should be

Text = Text & myvalue\100 & myvalue\10

Paul
 
Are you trying to declare a variable and name it using variables? I don't think this is allowed.
 
Sorry let me try again...
my var names will be like

text601
text602
:
:
text720

all of these get data assigned to them via a query.

so I'm trying to loop thru a variable naming procedure.
ie

text6 & X & Y

where x = 1 and y = 2

which willresult in the variable name:
text612

Is that clearer?
Jeff
 
yes Jables I am....
I really dont want to write:

text601 = someval
text602 = anotherval
:
:
text720 = yetanotherval

I guess the best way to handle this is in an array but how do i enumerate a block of textboxes via an arrray?

and how would I know where in the controlarray I am.

I know I can access my controls as an array but how do I say "Here is where we start looking"

As I under stand control arrays they are incremented in the order they are placed on the form or report. That is not the order I want to step thru them. 'cuz if i change my report even slightly that control array will change.
like say i add a control in my form that will cause all the controls after if to be incremented by 1 in my conrtols array.....

Any thoughts???
jeff
 
Hi,

You can enuerate the textboxes themselves using something like:

Code:
For intLoop = 600 To 700

  Me.Controls("Text" & intLoop)...

Next intLoop

Or some other method of enumerating them.

I might be way off, but I got the feeling that's what you are trying to do.

Dean :)
 
DeanWilliams is correct in that you can construct the control name as a variable, and use it as a key into the controls collection to obtain a specific control.

But what about the right hand side of the expression? How are you storing the values to be assigned, and how to store the mapping of which value to which control?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks Dean that was Exactlly what I was shooting for ....
You got a star
Jeff
 
The right side is the easy part.... the left was my prob.
Thanks for the input
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top