Looping with Multiple Controls

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
 
A

Allen Browne

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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top