Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using a variable as a control (2k)

    i have a bunch of controls that have name standards, ie: txtabc1, txtabc2, txtdef1, txtdef2, etc. i wrote 2 case statements in sequence to determine whether i need to use abc, or def, and then whether to use 1, or 2 (its actually much more, which is why i used a case statement). my problem is i want to do soemthing like:

    dim txtbox as string 'text box to setfocus to
    dim var1 as string 'abc or def
    dim var2 as string '1 or 2

    'var1 and var2 come from a case statement
    txtbox = "txt" & var1 & var2

    me.subform1.txtbox.setfocus

    i've found out that this doesn't work, and i don't know how i could do that... <img src=/S/bummer.gif border=0 alt=bummer width=15 height=15> but can this be done?? (pleeeeeeeease say yes!)
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Using a variable as a control (2k)

    You can use the Controls collection of a form to refer to a control using a string variable containing its name:

    Me.Subform1.Form.Controls(txtbox)

  3. #3
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using a variable as a control (2k)

    <img src=/S/hailpraise.gif border=0 alt=hailpraise width=27 height=22> <img src=/S/king.gif border=0 alt=king width=21 height=22>

    thats so cool! thanks!
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

Posting Permissions

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