Results 1 to 7 of 7
  1. #1
    witz07 is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    3

    change tab color or header color

    I built a form with 2 tabs. I would like to be able to change the tab color based on a pass/fail in a text box. I've been able to change color to the subform, header, and footer but not the tab using the VBA below. If the tab cannot be changed, I would like to change the color of the header for the main form based on pass/fail in a subform. Please help!



    If Me.L1 = "fail" Then

    FormFooter.BackColor = vbRed
    FormHeader.BackColor = vbRed
    Detail.BackColor = vbRed



    ElseIf Me.L1 = "pass" Then
    FormFooter.BackColor = vbGreen
    FormHeader.BackColor = vbGreen
    Detail.BackColor = vbGreen

    Else
    Detail.BackColor = 16777215
    FormFooter.BackColor = 16777215
    FormHeader.BackColor = 16777215

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    This should work:

    If Me.L1 = "fail" Then
    FORM_YourMainForm.FormHeader.BackColor = vbRed
    ElseIf Me.L1 = "pass" Then
    FORM_YourMainForm.FormHeader.BackColor = vbGreen
    Else
    FORM_YourMainForm.FormHeader.BackColor = 16777215
    END IF





  3. #3
    witz07 is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    3
    This works temporarily, meaning the color changes as I expect but it does not save. When I pull up the record again, the header is back to the regular background. How do I save it so each time I enter the persons name I will see the background either green or red based on pass/fail?

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    I'm not sure where you have that code now, but you may want to include it in the form's OnCurrent event.

    The color's are only reflected on the form, they are not saved with the underlying record. Colors are typically used as a notification/identifier/signal to the user.

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Try placing that code in the On Current event of the subform. It will then run every time you move to a new record in the subform.

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    What event invokes the code now?

  7. #7
    witz07 is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    3
    This took care of it. Thanks so much!

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

Similar Threads

  1. Replies: 1
    Last Post: 03-11-2016, 01:27 PM
  2. change color of a buttons
    By azhar2006 in forum Forms
    Replies: 1
    Last Post: 10-29-2014, 06:15 AM
  3. Changing form header color
    By Demerit in forum Forms
    Replies: 10
    Last Post: 12-20-2013, 02:27 PM
  4. Replies: 5
    Last Post: 08-26-2013, 01:26 PM
  5. change cell color
    By bishop743 in forum Programming
    Replies: 0
    Last Post: 02-01-2009, 11:00 AM

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