Results 1 to 4 of 4
  1. #1
    omahadivision is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    21

    Referencing a textbox using variable values from a function?

    Hello all,

    I have a question that seems quite simple but has confused me. I made a button that asks users for data and then analyzes it, and places the results in a textbox. The code is fairly complex, and since there are 30 such textboxes, I decided to make a function for it. For each Call Function command I write, I also send the name of the textbox where the value will ultimately be stored, as a string.

    Without the function, it's easy. For one textbox I just put in the code:
    Code:
    me.Textbox.value=calculatedvariable
    With the function, it seems much harder. I tried
    Code:
    me.variablerepresentingtextbox.value=functionvariable
    I know that the function is set up correctly, because when I view both the variables, I get the right answers. When I substitute the original Textbox back into the function instead of variablerepresentingtextbox, it works. But I can't get the function variable to be used as the name of the textbox and always get an error. Is there some command to turn the value of the variable into a reference to a textbox?



    Thanks!

    -Dave

  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,518
    Try

    Me(VariableName)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    omahadivision is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    21
    Quote Originally Posted by pbaldy View Post
    Try

    Me(VariableName)
    Super simple but would have taken a long time to guess. Thanks!

  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,518
    No problemo!
    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. Replies: 2
    Last Post: 12-10-2012, 02:23 PM
  2. Referencing values within queries
    By sf827 in forum Queries
    Replies: 9
    Last Post: 12-19-2011, 05:49 PM
  3. Fill data entry textbox with variable
    By broecher in forum Forms
    Replies: 6
    Last Post: 11-18-2011, 07:54 PM
  4. Replies: 4
    Last Post: 05-16-2011, 04:58 PM
  5. Replies: 3
    Last Post: 10-15-2010, 11:17 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