Results 1 to 5 of 5
  1. #1
    accote is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    35

    Question Change color of a form depending on the value of a variable

    Hello All and Thank You for any help you can provide. I'm trying to have my form change colors depending on
    the record selection. There will be 4 categories, so 4 different form colors. I can do it fine in the details section
    of the form with the code below, but the FormHeader Section does not change. My Question: what can I do to
    change the Header also, or what is wrong with my code below?


    Private Sub cboGoToContact_Change()
    strProjStatus = Me.InstitutionType

    Select Case strProjStatus


    Case "College"
    Me.Section(acFormHeader).BackColor = RGB(77, 62, 80)
    Me.Section(acDetail).BackColor = RGB(213, 204, 218)
    Case "Grad School"
    Me.Section(acDetail).BackColor = RGB(181, 283, 106)
    Case "University"
    Me.Section(acDetail).BackColor = RGB(198, 228, 220)
    Case "Individual"
    Me.Section(acDetail).BackColor = RGB(242, 242, 242)
    End Select

    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I tested code to set the FormHeader BackColor property and it worked. Can't replicate your issue.

    Could try
    Me.FormHeader.BackColor = RGB(77, 62, 80)

    Only want the FormHeader color to change for the value "College"?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    accote is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    35
    Hi, thanks for the reply.
    It might has to do with the fact that my form is a multiple page form, with tabs?
    I did try "Me.Section(FormHeader).BackColor" but that didn't work either.
    I need both the header and details part of the form to change to different colors.
    Weird part is if I leave only the "Me.Section(acFormHeader).BackColor" in it will
    change the details section too, and never the header.

  4. #4
    accote is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    35
    June7, you were right on, took out the section and ac part and everything works like a charm. Thank You very much.

    Working Code:

    Private Sub cboGoToContact_Change()
    strProjStatus = Me.InstitutionType

    Select Case strProjStatus
    Case "College"
    Me.FormHeader.BackColor = RGB(77, 62, 80)
    Me.Detail.BackColor = RGB(213, 204, 218)
    Case "Grad School"
    Me.FormHeader.BackColor = RGB(0, 34, 33)
    Me.Detail.BackColor = RGB(198, 228, 220)
    Case "University"
    Me.FormHeader.BackColor = RGB(67, 66, 49)
    Me.Detail.BackColor = RGB(212, 219, 199)
    Case "Individual"
    Me.FormHeader.BackColor = RGB(44, 23, 0)
    Me.Detail.BackColor = RGB(255, 237, 217)
    End Select

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Not sure what you mean by 'multiple page'.

    cboGoToContact is a bound control?

    Might need code in the form Current event as well as the combobox event.

    My suggestion was for Me.FormHeader, not Me.Section(FormHeader). However, my suggestion will probably produce same result as your original code.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Change color on a button on a form
    By helpme1 in forum Forms
    Replies: 1
    Last Post: 01-13-2012, 12:59 PM
  2. change a combobox value depending on another
    By emadaldin in forum Access
    Replies: 3
    Last Post: 01-17-2011, 01:06 PM
  3. Replies: 3
    Last Post: 07-05-2010, 10:46 PM
  4. Change the text box color on form load
    By mikec in forum Programming
    Replies: 2
    Last Post: 03-01-2010, 11:47 PM
  5. Color change in form filed
    By miziri in forum Programming
    Replies: 3
    Last Post: 08-15-2009, 04:53 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