Access VBA

Excel VBA
Excel Formulas
User-defined Functions
Office Links
Access VBA
Access SQL
Alan’s Excel FAQ
Excel Home
Alan’s Home

Alternating Report Color Rows

This example causes the rows in the report to be alternating in Pink, White, and Blue. Change the RGB values around to find your favorite.

The code goes into the Build Event for the DETAIL. In the case of a particularly long or detailed report, 3 colors really beats all white.

Private RowNumber       As Long

 

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    RowNumber = RowNumber + 1
    If RowNumber Mod 4 = 1 Then
        Me.Detail.BackColor = RGB(255, 204, 204) 'Pink
    Else
        If RowNumber Mod 2 = 1 Then
            Me.Detail.BackColor = RGB(204, 204, 255)
        Else       'Blue

            Me.Detail.BackColor = vbWhite
        End If
    End If
End Sub

Remember, change the background of the fields to Transparent so the color shines through.

© 2008-2009

Updated:  11/16/2009 23:41
This page added:  26 October 2008