Results 1 to 6 of 6
  1. #1
    mikenyby is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2022
    Posts
    4

    Conditional formatting a text box and label based on other fields

    Hello!

    I am trying to make certain fields on a report visible or invisible based on values in another field.

    I have a field [Status_SchoolStatus] that is a lookup field with two options: "Currently Active" or "Closed"

    I have one field, [Year of Closing], I would like to hide if [Status_SchoolStatus] = "Currently Active"

    I have two fields, [School Website] and [School Phone Number] I would like to hide if [Status_SchoolStatus] = "Closed"

    I have managed to make this work fine by conditionally formatting the text boxes to appear with white text (same colour as the background), using Expression Is [Status_SchoolStatus] = "Closed" and [Status_SchoolStatus] = "Currently Active" and setting the appropriate font colour for each.

    However, this does not affect the labels. Is it possible to format the labels as well?

    I've searched through a few forums and a common answer was to change the labels to text boxes, but that opens up a whole can of worms regarding control sources, and I can't get the labels that I turn into text boxes display the desired text, they'll either display the text in the associated text box or bring up a parameter input dialogue when I try to run the report.

    I would like the labels for each of these fields to display "School Website", "School Phone Number" and "Closing date", respectively.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    instead of conditional formatting,
    just put in a function to colorize the textbox.

    Code:
    select case true
     case A=1
        txtBox.backcolor  = vbRed
    
    
    case B=2 txtBox.backcolor = vbWhite
    end select

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    You can also set it visible or not?
    I would likely set the visible property of the label to the visible property of the textbox and control just that?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    mikenyby is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2022
    Posts
    4
    Will this also colourize the labels? What I'm really struggling with is getting my labels to disappear when I want them to.

    And excuse the absolute novice question, but where do I put that function?

  5. #5
    mikenyby is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2022
    Posts
    4
    Quote Originally Posted by Welshgasman View Post
    You can also set it visible or not?
    I would likely set the visible property of the label to the visible property of the textbox and control just that?

    I can set them both visible or not in the properties box, but how can that be controlled by the value of [Status_SchoolStatus]?

  6. #6
    mikenyby is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2022
    Posts
    4
    Quote Originally Posted by ranman256 View Post
    instead of conditional formatting,
    just put in a function to colorize the textbox.

    Code:
    select case true
     case A=1
        txtBox.backcolor  = vbRed
    
    
    case B=2 txtBox.backcolor = vbWhite
    end select
    Will this also colourize the labels? What I'm really struggling with is getting my labels to disappear when I want them to.

    And excuse the absolute novice question, but where do I put that function?

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

Similar Threads

  1. Replies: 2
    Last Post: 10-13-2020, 12:19 AM
  2. Replies: 4
    Last Post: 06-12-2018, 03:37 PM
  3. Conditional Formatting of a Label
    By rmilsley in forum Forms
    Replies: 5
    Last Post: 08-21-2013, 03:48 PM
  4. Conditional Formatting of a text-box
    By GraeagleBill in forum Forms
    Replies: 9
    Last Post: 04-06-2013, 11:22 PM
  5. Conditional Formatting of a label
    By pbparady in forum Access
    Replies: 1
    Last Post: 01-31-2012, 01:12 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