Results 1 to 3 of 3
  1. #1
    Vita's Avatar
    Vita is offline Competent Performer
    Windows 10 Access 2002
    Join Date
    May 2022
    Location
    Massachusetts, USA
    Posts
    296

    Enumerating Controls?

    I have several controls that I wanted to enumerate through and they are numbered TestControl0 to TestControl15


    I was trying to use a for loop to enumerate through them and append the loop number onto the end of the control but it looks for the control before appending the number.

    Here is some code I was trying
    Code:
        Dim CtrlTst As Control, i
    
    
            CtrlTst = Me.ControlTest(i)
            'I also tried CtrlTst = Me.ControlTest + i
            'And CtrlTst = Me.ControlTest & i
    
    
            With CtrlTst      'Also tried putting [With (CtrlTst + i)]
                .Visible = True
            End With
    Is this something that is possible? I wanted to avoid a large Select Case list

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Try

    Me.Controls("TestControl"& i)
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Vita's Avatar
    Vita is offline Competent Performer
    Windows 10 Access 2002
    Join Date
    May 2022
    Location
    Massachusetts, USA
    Posts
    296
    Quote Originally Posted by Minty View Post
    Try

    Me.Controls("TestControl"& i)
    This worked perfectly! Thanks!

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

Similar Threads

  1. Replies: 14
    Last Post: 03-23-2023, 05:45 AM
  2. Using Tab Controls
    By NadiaWilkes in forum Programming
    Replies: 7
    Last Post: 02-14-2020, 06:07 PM
  3. Replies: 12
    Last Post: 09-11-2018, 04:46 PM
  4. Replies: 3
    Last Post: 04-29-2017, 12:09 PM
  5. Enumerating records in a table
    By EricMK in forum Programming
    Replies: 5
    Last Post: 07-08-2009, 07:40 AM

Tags for this Thread

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