Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002

    Unanswered: Using variables to refer which textBox has to be changed

    I want to use VBA sub to change a property of a textbox. I know how to change the property if I write the complete name of the textbox, but how does it works when the name depends on a variable.
    I've got a few textbox's named text1, text2, text3 etc.
    when I start my sub a variable i is set to a number ( for example "2")
    So in that case I want to change the properties off 'text2'

    I tried something like this:
    Set fld = Forms![FormName].Controls![Text& i]
    but no luke

    any suggestions

  2. #2
    Join Date
    Nov 2002
    San Francisco
    this is more for everybody who uses EXCLAMATION.

    FORGET IT NOW!!!!!!!!!!!!!!!!!!!!!!!

    there are few situations, where you have to use it (query refers to value from the form, ....), but generally you don't need to use it at all.

    replace Forms![FormName].Controls![Text& i]


    Forms("FormName").Controls("Text" & i)


Posting Permissions

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