Alternating Color Irregularities when grouping

WorkingVBA

Registered User.
Local time
Today, 03:53
Joined
Jul 3, 2013
Messages
33
I kind of solved this one already, but was wondering if I had missed something before. If I did not, someone else might be able to use this.

I have a simple continuous report, and I was using the alternating row color feature. Then I decided that I wanted one group separated by a thin line rather than a group header (vertical space was an important factor). So I set up the group containing only a thin line, and when I ran my report I noticed that my beautiful alternating colors were all screwed up like:
White
Grey
White
White
White
Grey
White
And so on​
This simply would not do. I played around with the group header's alternating color property, turning it off ("No Color") and on, but to no avail. A Google search did not really bring me any answers either.

So instead I turned the grouping off and placed a hairline, named "lneSector", at the top of the detail area, above the fields and added the following code for the On_Load and Detail_Print events:
Code:
Option Compare Database
Option Explicit

Dim pPrevSector As String

Private Sub Report_Load()
    [COLOR="SeaGreen"]' Initialize the previous sector (pPrevSector) sting[/COLOR]
    pPrevSector = ""
    
End Sub

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    [COLOR="SeaGreen"]' The Detail_Print event will make a line in the report's detail
    ' visible when a new sector starts. This was done because there
    ' was no way to avoid the alternating row color irregularities
    ' caused by grouping the data in the report

    ' If pPrevSector = Sector then[/COLOR]
    If pPrevSector = Sector Then
        [COLOR="SeaGreen"]' Make the line "lneSector" invisible[/COLOR]
        lneSector.Visible = False
    Else [COLOR="SeaGreen"]' pPrevSector <> Sector Or pPrevSector = "" (first time around)[/COLOR]
        [COLOR="SeaGreen"]' Make the line "lneSector" visible[/COLOR]
        lneSector.Visible = True
        [COLOR="SeaGreen"]' Set pPrevSector equal the current sector[/COLOR]
        pPrevSector = Sector
    End If [COLOR="SeaGreen"]' pPrevSector = Sector[/COLOR]
    
End Sub
 

Users who are viewing this thread

Back
Top Bottom