Results 1 to 8 of 8
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Conditional formatting for text boxes with same tag

    I've tagged a bunch of boxes with the same tag in the properties.



    "greyout"

    I want to apply a conditional formatting to those textboxes with that tag if a value is true.

    so if checkboxed then

    greyout all boxes with conditional formatting.

    I'm thinking along the lines of..
    Code:
    Dim ctl As Control
    
    If JoiningSchool = True Then
    For Each ctl In Me.Controls
    If ctl.Tag = "greyout" Then
    How?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Very close...

    When you say "greyout", do you want them to be disabled?

    try:
    Code:
        Dim ctl As Control
    
        If JoiningSchool = True Then
            For Each ctl In Me.Controls
                If ctl.Tag = "greyout" Then
                    ctl.Enabled = False
                End If
            Next
        Else
            'JoiningSchool = False
            For Each ctl In Me.Controls
                If ctl.Tag = "greyout" Then
                    ctl.Enabled = True
                End If
            Next
        End If

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Nah, it's a subform and I just block out the whole subform. However I would like to know how to apply conditional formatting to anything with the tag. (I want to change from colour to grey so the user knows they don't have access to it).

  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,652
    Or simply

    Code:
    For Each ctl In Me.Controls
      If ctl.Tag = "greyout" Then
        ctl.Enabled = Not JoiningSchool
      End If
    Next
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by pbaldy View Post
    Or simply

    Code:
    For Each ctl In Me.Controls
      If ctl.Tag = "greyout" Then
        ctl.Enabled = Not JoiningSchool
      End If
    Next
    thanks but I'm actually after changing the formatting (although I will be using your code supplied)

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

    (I want to change from colour to grey
    What color?? The font or the background?

    so the user knows they don't have access to it).
    How does changing the color limit access??

  7. #7
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by ssanfu View Post


    What color?? The font or the background?


    How does changing the color limit access??
    heh it doesn't, but combined with locked it gives them a visual feedback before they have tried to click in the field. Yes, Font and background color.

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    In your form, change a control for the enabled property to NO. The background and the font colors change.
    As a bonus, you cannot make changes or even set the focus to the control.

    Is that what you want?

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

Similar Threads

  1. Conditional Formatting of a text-box
    By GraeagleBill in forum Forms
    Replies: 9
    Last Post: 04-06-2013, 11:22 PM
  2. Replies: 3
    Last Post: 02-07-2013, 09:53 PM
  3. Replies: 2
    Last Post: 01-21-2013, 10:38 PM
  4. Replies: 5
    Last Post: 08-20-2012, 11:11 PM
  5. Conditional Formatting of Text Boxes
    By beribimba in forum Reports
    Replies: 2
    Last Post: 03-09-2012, 05:08 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