Results 1 to 12 of 12
  1. #1
    jmk0576 is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    7

    Conditional formatting on group header


    Is it possible to conditionally format a group header. I would like the background color and title to change when group changes. I understand how to set it within the detail section on a specific field but need to change the title of the group header when group changes. Any suggestions would be appreciated. Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Don't understand what you mean by 'change the title of the group header'. Should that have been 'change the color'?

    Do you just want the background color to alternate between two colors so each group is distinguished from neighbor group? Try setting the Alternate Back Color property to 'Alternate Row'.
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm not sure I understand. By definition, wouldn't the title change when the group changes? Can't you just change the color of the group section in design view?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    jmk0576 is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    7
    Yes, I want to change the background color in the group header as well as change the text. The text and background color will be based on the value of the field I used in the group. For example, Group One is Yellow and this grouping is for projects in the vetting stage, Group Two is Blue and is for projects in the budgetting phase .....

    I was not able to find an option to dynamically change the group header.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Here's a quick and dirty example:

    Code:
        If Me.FieldName = 1 Then        
            Me.GroupHeader0.BackColor = vbYellow
        Else
            Me.GroupHeader0.BackColor = vbWhite
        End If
    I might have the options in a table, but this should get you started.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    jmk0576 is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    7
    Thanks for the code... where do I place it.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Sorry, the format event of the group header section.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Be aware OnFormat event only triggered when printed or PrintPreview, not Report View.
    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.

  9. #9
    jmk0576 is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    7
    Thank you very much it works the first time it is displayed in print preview. However, If I scroll thru the pages intially all the colors are correct but when I go back the colors change to the last one that was displayed. Do I need to add this to another Event to eliminate this issue.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I don't get that behavior in my test. What exactly is your code? Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    jmk0576 is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    7
    I resaved everything and it is working ... code was only in the Format event for the Section. Thanks, again completed.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 04-06-2014, 10:58 AM
  2. Replies: 6
    Last Post: 05-26-2013, 09:10 PM
  3. Replies: 0
    Last Post: 02-25-2013, 04:43 PM
  4. Group Header
    By SusanHRO in forum Reports
    Replies: 5
    Last Post: 08-10-2011, 01:59 PM
  5. columns for group detail but not group header?
    By Coolpapabell in forum Reports
    Replies: 0
    Last Post: 08-21-2009, 08:53 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