Consulting

Results 1 to 4 of 4

Thread: Solved: Indirect reference for form controls

  1. #1

    Solved: Indirect reference for form controls

    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.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    For Lane = 1 to 6

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

    .

    Next Lane
    [/vba]

  3. #3
    Thanks. Saved me hours of browsing the help files.

    Much Appreciated.

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Subwayman,
    Welcome to VBAX.
    If your question is solved, you can mark it so using the thread tools dropdown.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •