Freedom Computers

ACCESS

How to Shade alternate rows in a report.Shading colour or color alternate lines

Put the following code in the ON FORMAT EVENT of the reports DETAIL Option

Compare Database
Option Explicit
Private shadenextrow As Boolean
Const shadedcolor = 12632256
' alternative shade colors
' Const shadedColor = 15726583
' Const shadedColor = 14078404
' Const shadedColor = 13356495
' Const shadedColor = 14281974
Const normalcolor = 16777215
--------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo Detail_Format_Error

' Choose a color based on the shadeNextRow value
If shadenextrow = True Then
Me.Section(acDetail).BackColor = shadedcolor
Else
Me.Section(acDetail).BackColor = normalcolor
End If

' Switch the color for the next row
shadenextrow = Not shadenextrow

Detail_Format_Exit:
Exit Sub

Detail_Format_Error:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Detail_Format_Exit

End Sub