Results 1 to 3 of 3
  1. #1
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    172

    How to use a vairable to reference a field (not the field contents)?

    I have many boxes (they are actually 'text box labels') named tBox1, tBox2, and etc. Each is filled from another form (the proposal form) as jobs are received. Upon accepting a job, text (job name) is added to one of these boxes depending on the job date. The text is also colored depending on the type of work. They use 3 colors.



    Currently, the program is only partially written and they have hundreds of lines of code because it has to go through several 'select case' function listing each object as:

    select
    case 1
    ![tBox1].caption = "strJobName"
    case 2
    ![tBox2].caption = "strJobName"
    etc

    This is an example. There is a lot more to it. Now, my question. Can those boxes be referenced using some type of variable insteadd of listing each one; or is there another way to do it? Thanks for your help.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    That Select Case code syntax is not correct anyway. Should be:

    Select Case variable
    Case 1
    ...

    You want to construct control name with a variable? Is "strJobName" supposed to be a variable or static text? Try:

    Me("tBox" & variable).Caption = strJobName
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    172
    That works SO good. Thank you very much.

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

Similar Threads

  1. Replies: 11
    Last Post: 07-05-2013, 08:00 AM
  2. Replies: 3
    Last Post: 05-23-2011, 07:29 AM
  3. Replies: 0
    Last Post: 03-29-2011, 04:11 PM
  4. Copy contents of one field to another
    By 10 Gauge in forum Forms
    Replies: 4
    Last Post: 02-11-2011, 09:51 AM
  5. Remove contents from each field
    By nancyszn in forum Access
    Replies: 7
    Last Post: 08-06-2009, 03:41 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