Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Group Backcolor (97/sr1)

    Really straight forward - or so it should be.
    Changing alternate lines in a detail is no problem.
    But now when trying to change the background of the group I seem to be having difficulties and what appears to be random result.
    For changing alternate detail lines I use (simplified)
    <pre>Const adhocWhite = 16777215
    Const adhocGreen = 8454016
    Me.Detail.BackColor = iif(Me.Detail.BackColor = adhocWhite,adhocGreen,adhocWhite)
    </pre>


    Applying similar to group becomes
    <pre>Const adhocWhite = 16777215
    Const adhocGreen = 8454016
    Dim lngColor As Long

    If Me.GroupHeader0.BackColor = adhocWhite Then
    lngColor = adhocGreen
    Else
    lngColor = adhocWhite
    End If
    Me.GroupHeader0.BackColor = lngColor
    Me.Detail.BackColor = lngColor</pre>


    the group color to begin with is white (16777215)
    results in first two pages all green
    remaining 6 pages all white

    TIA
    Alan
    wet in Cheshire

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Group Backcolor (97/sr1)

    Code to change the color of the detail section should be in the On Format event of the detail section itself. If you put it in the On Format event of the group header, the background color of all detail records in a group will be the same.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Group Backcolor (97/sr1)

    That's essentially what the guy wants so I guess I was in the right area.
    The end result should be that each alternate group (plus it's details) should be one color, that color alternating between white and green.
    e.g.
    group1+details = white
    group2+details = green
    group3+details=white
    et cetera

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Group Backcolor (97/sr1)

    I tried your code in the On Format event of the group header of a report, and it works as intended - the group header and all its detail records are colored alternatingly green and white - see screenshot.

  5. #5
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Group Backcolor (97/sr1)

    Most strange.
    Many thanks Hans, I need to check other areas then to see if set up is correct.
    report set up is:
    report header
    page header
    group header
    detail
    page footer
    report footer

    Nothing jumps out but thanks for the reponses.
    Cheers
    Alan

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Group Backcolor (97/sr1)

    Check if there is other code that sets the background color, e.g. in the On Format event of the page header or something like that.

  7. #7
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Group Backcolor (97/sr1)

    Result......
    grouping had "keep together=Whole Group"
    when this was set to NO then the backcolor has worked precisely as expected.

    Who'd have thought?!

    Regards
    Alan

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Group Backcolor (97/sr1)

    Try the following:
    - Put a text box in the group header.
    - Set its Visible property to No.
    - Set its Control Source to =1
    - Set its Running Sum property to Over All (or Over Groups).
    - Set its Name to txtCount.
    - Change the condition

    If Me.GroupHeader0.BackColor = adhocWhite Then

    to

    If Me.txtCount Mod 2 = 0 Then

    You should now be able to set Keep Together to Whole Group again and still have the groups colored correctly.

  9. #9
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Group Backcolor (97/sr1)

    Good move Hans.
    All sorted now thanks and using your suggestion the grouping stays together.

    Thanks
    Alan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •