Results 1 to 9 of 9
  1. #1
    540MahoneyJF is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2021
    Posts
    5

    Access Form Changing Colors when checkbox selected

    Good Day,



    I have a database where it manages team members files. Within the main form there is a sub form for member info which contains a checkbox (Flag_Member_File). When the checkbox is checked, I want the subform to turn its background color to Red. I have tried researching on here but I haven't had any luck. Can anyone assist with the code for the form to do that?

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    If the subform is a data sheet I think the answer is, you cannot, so what is it? Then what's supposed to happen if the box is unchecked (no one ever seems to think about that in these requests)?

    Use the checkbox AfterUpdate event to set the subform detail colour property. If the control is True (you don't need the Value property) then change the colour.

    The subform reference would be
    Code:
    Forms!YourFormName.YourSubformCONTROLname.Form.Detail.Backcolor =
    NOTE subformcontrolname is the name of your subform control which not necessarily the name of either form.

    To restore the colour if box is unchecked you'd need to know what it was before while testing for both True and False and acting accordingly.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    540MahoneyJF is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2021
    Posts
    5
    Hi the subform is a form with member details laid out in fields for data entry. The checkbox when checked would be used to flag a members file and then turn the background colour red. When the checkbox is unchecked it should return the form back to original colour of white.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I would look at conditional formatting.?
    https://www.google.com/search?q=acce...hrome&ie=UTF-8
    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

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    That doesn't tell me if the subform is a data sheet or not. Could be continuous or single record form. Either would work but each of those would require a different event. Datasheet not possible. So I'd rather not delve into this only to have you tell me it doesn't work and it turns out that is because it's a datasheet view. Or it doesn't work because it's a single record view and the background is red no matter who's record you're looking at. Quite simple to figure out what the form is at your end and let me/us know.

    To clarify, you want the background of the whole subform to become red just because one record has a checked box? You could also copy/compact/zip and upload your file here and eliminate some back and forth.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Quote Originally Posted by Welshgasman View Post
    I would look at conditional formatting.?
    You can alter form detail section colour with cf?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    540MahoneyJF is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2021
    Posts
    5
    Hi, the form is a single record form. Not a data sheet or continuous form. And yes I want the background of the whole subform to change to red if the checkbox is checked with it going back to normal when it’s unchecked.

  8. #8
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Then you will need to use the current event (at least I'm assuming user is navigating from one record to another)
    Code:
    Private Sub Form_Currrent()
    If Me.Check6 = True Then
       Me.Child4.Form.Detail.BackColor = vbRed
    Else
       Me.Child4.Form.Detail.BackColor = vbWhite
    End If
    
    End Sub
    Use your own object names for the checkbox and subform control (Check6 and Child4).
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by Micron View Post
    You can alter form detail section colour with cf?
    No, I was thinking of the controls. Sorry

    Could perhaps piggyback off the fore/back color of a control set by CF ?
    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

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

Similar Threads

  1. Replies: 1
    Last Post: 09-10-2018, 01:26 PM
  2. Replies: 4
    Last Post: 05-30-2016, 10:53 AM
  3. Multiple Checkbox selected at once
    By Adish in forum Forms
    Replies: 3
    Last Post: 10-12-2015, 07:21 PM
  4. Replies: 3
    Last Post: 02-08-2015, 01:30 PM
  5. Globally changing colors on forms
    By pwdpwd in forum Programming
    Replies: 2
    Last Post: 11-23-2010, 09:06 PM

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