Alternate row color in an Access Report

This tip shows you how to use VBA to alternate the row color of an Access report. Many times, when creating a report, we find it hard to read the details. By alternating the row color we can make life much simpler:

1
2
3
4
5
6
7
8
9
10
   Private rowCount As Long
 
   Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)            
      rowCount = rowCount + 1
      If rowCount / 2 = CLng(rowCount / 2) Then
         Me.Detail.BackColor = 16777215
      Else
         Me.Detail.BackColor = 15263976             
      End If
  End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *