PDA

View Full Version : Solved: Indirect reference for form controls



subwayman
05-18-2007, 10:39 AM
Newbie question:

I have a form with six rows of textboxes used to enter the results of a race.

Each row has text boxes named 'Lane1name', 'Lane1Position' . . .

I want to process this data in loops so need to refer to the control values indirectly. Something like:

For Lane = 1 to 6

controlname = "Lane" + format(Lane,"#") + "name"

currentlanename = controlname.value

.

.

Next Lane

Anyone got the magic answer?

Thanks in advance.

Bob Phillips
05-18-2007, 11:47 AM
For Lane = 1 to 6

currentlanename = Me.Controls("Lane" & i & "name").Text
.

.

Next Lane

subwayman
05-18-2007, 11:53 AM
Thanks. Saved me hours of browsing the help files.

Much Appreciated.

mdmackillop
05-18-2007, 01:27 PM
Hi Subwayman,
Welcome to VBAX.
If your question is solved, you can mark it so using the thread tools dropdown.