Results 1 to 4 of 4
  1. #1
    BallinWallin is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    11

    Using Variables to Refer to Form Objects

    Hello and thank you for taking the time to read my question.



    In its simplest, is it possible to use variables to refer to text boxes on a form? Essentially, I have X text boxes named something like TextBox1, TextBox2,...TextBoxX. I want to save the value of Y textboxes (Y < X) to a table but Y comes from the user. I had imagined using a do loop for i = 1 to X and the problem I'm running into is referring to the text boxes in a line like the following:

    .fields("Field") = me.("TextBox" & i)

    Is this even possible? If not, are there any suggestions? Thank you very much.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Close:

    .fields("Field") = me("TextBox" & i)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    BallinWallin is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    11
    I just realized I never responded... It worked perfectly (as I'm sure you're not surprised), thank you so much.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problem and happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to refer to fields in subforms from Main form
    By JrMontgom in forum Programming
    Replies: 1
    Last Post: 03-09-2014, 06:35 PM
  2. Replies: 5
    Last Post: 11-12-2013, 12:14 AM
  3. Replies: 3
    Last Post: 09-08-2011, 04:40 PM
  4. How do you refer to primary key on split form?
    By techneophyte in forum Forms
    Replies: 3
    Last Post: 08-13-2010, 08:11 AM
  5. Refer to main form
    By terryvanduzee in forum Forms
    Replies: 3
    Last Post: 10-23-2009, 07:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums