Results 1 to 3 of 3
  1. #1
    gr000953 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    2

    Manipulate controls (Rectangles) on a Form

    i have multiple unbound rectangle controls on a form (say 100 or so named Box00, Box02,...Box99 ). I assign each rectangle to a group (A to Z) using the Tag value for the control. In my application I want to be able to click one of 26 control buttons (A, B, C .....Z) and the rectangles that belong to that group will be displayed differently.

    The main thing I'm looking for is how to write VBA code that operates on all the boxes without me having to code their names individally. Ie is there a way to say

    For all rectangle controls in this form
    ...do this


    ...and this
    Next

    Otherwise I am confident I could write the coding as follows but it seems inefficient (Please ignore the VBA syntax accuracy..newbie who dabbles ocassionally...I'm not looking for spell checks at this point, just logic/command flow help and what's possible before I beat my head against a wall.

    If Box00.Tagvalue= MatchTag
    Box00.BorderWidth =6
    Else
    Box00.BorderWidth =1
    EndIf


    If Box01.Tagvalue= MatchTag
    Box01.BorderWidth =6
    Else
    Box01.BorderWidth =1
    EndIf

    If Box02.Tagvalue= MatchTag
    Box02.BorderWidth =6
    Else
    Box02.BorderWidth =1
    EndIf

    ....... up to Box99

    ....
    Next





  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    that is too much work for a form.
    but,

    Code:
    dim ctl
    For Each ctl In Controls
        If TypeName(ctl) = "Textbox" Then
            If ctl.Tagvalue = MatchTag Then
               ctl.BorderWidth = 6
            Else
                ctl.BorderWidth = 1
            End If
        End If
    Next

  3. #3
    gr000953 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    2
    Thanks you!! It worked just fine.

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

Similar Threads

  1. Proper Way to Look Up and Manipulate files
    By SodaPop in forum Access
    Replies: 4
    Last Post: 01-05-2018, 10:25 PM
  2. Manipulate Excel Data
    By jo15765 in forum Programming
    Replies: 6
    Last Post: 05-15-2017, 11:39 AM
  3. Manipulate Forms
    By Milade8080 in forum Forms
    Replies: 6
    Last Post: 07-14-2014, 12:51 PM
  4. Using VBA to manipulate properties in a Report
    By adacpt in forum Programming
    Replies: 1
    Last Post: 11-26-2012, 09:22 PM
  5. Manipulate DB through VB ...
    By Zoroxeus in forum Programming
    Replies: 2
    Last Post: 12-18-2005, 01:16 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