Looping with Multiple Controls

  • Thread starter Thread starter trekgoes2malaysia
  • Start date Start date
T

trekgoes2malaysia

I am having problems assigning the values of several repetitive
textbox controls to an array. I can't seem to get the event procedure
to save the values to the array rather than the name of the control:
Below is my code:

Dim z(21) as variant

For i=1 to 21
z(i) = "Me.t" & i & ".Value"
Next

This returns the following ...
z(1)= Me.t1.Value

rather than the desired....

z(1)=43.5 (the value in the Me.t1 control)

Any ideas how to get my desired outcome.

Patrick
 
Try:
z(i) = Me("t" & i)

The exrpession
Me.("City")
is short for:
Me.Controls("City")
 
Back
Top