Results 1 to 8 of 8
  1. #1
    RexRivers is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    4

    Using Data from a Text Box

    I have a variable t that represents a text box.


    It's being used in a For statement so the name of the text box is always changing. I'd like to capture the value of the box each time in the loop. How do I do this?
    t.value doesn't work as well as a whole list of other things I've tried.

    *Edit - the For statement is For Each ctr in Controls

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    what do you mean t.value doesn't work?

    it should work. just make sure the control is textbox. t.value doesn't work if t is a lable or other object that doesn't have a value field. in that case you will get an error.

  3. #3
    RexRivers is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    4
    I get "Compile Error: Invalid Qualifier" for the variable t.
    I can do MsgBox (t) and it shows "txtSCrkH1" which is the name of the text box in question, but as soon as I add .value I get the compile error

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    How do you define T? I do as following and it works well except T goes to an object without value:

    dim T as object

  5. #5
    RexRivers is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    4
    Ok, I had t as string. I've changed it to object.
    The line as I had it before was:
    t = ("txt" & Mid(ctl.Name, 4, (l - 3)))
    Now I added Set to the front of that (Set t =...) and it's saying "Object required"
    This is pretty new territory for me. Thank you for helping.

  6. #6
    Join Date
    Apr 2010
    Posts
    21
    Why bother with t at all. Just reference the name of the control as ("txt" whatever) =

  7. #7
    RexRivers is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    4
    t is in a For statement that is going through about 80 controls. Little background: The form represents a weekly match between 2 dart teams. The text boxes contain the player's roster number. Each text box has a check box next to it that is marked true noting that player won. The text box and check box have the same name except for the prefix (chk or txt).
    When the two teams are chosen from Combo boxes, data is pulled from a players table that populates labels with player roster # and Name. Those roster #s are manually entered into the text boxes "t" . Everything works fine up to this point. I want to add check boxes next to the player's labels and have them marked true if the roster # was used during that match because we tally how many weeks during a season someone participates.

    t works when I'm using it in SQL "WHERE [RosterNumber]=" & t & ";"

  8. #8
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    since you for each ctr, you don't need a t any more, just use ctr.
    for each ctr in controls
    messagebox(ctr)
    next

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

Similar Threads

  1. Add Text to chart when data = 0
    By mikesr in forum Reports
    Replies: 1
    Last Post: 07-23-2010, 08:21 AM
  2. Importing text data
    By gsashwin in forum Import/Export Data
    Replies: 1
    Last Post: 06-28-2010, 06:40 PM
  3. Extract Text Data
    By tmcrouse in forum Queries
    Replies: 5
    Last Post: 05-25-2010, 11:34 AM
  4. Data from text file
    By Directlinq in forum Programming
    Replies: 1
    Last Post: 10-19-2009, 02:29 AM
  5. Filter non-text data
    By bdriscoll in forum Access
    Replies: 2
    Last Post: 09-25-2009, 05:49 PM

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