Reports: Highlight Every Other Row

Wednesday, March 26, 2003 22:58:07
home

There are two different methods: One I derived from Chapter 9 of the Access 2000 Developer's Handbook, although strangely enough it didn't seem to work with an Access 2000 database running on Access XP at home. (It worked fine on an Access 2000 database at work.) I instead found this alternate method from the newsgroup microsoft.public.access.reports, thread entitled Access 97; Report Formatting, dated July 20th 2002.

  • Make sure the BackStyle of each control is transparent
  • Enter the following code into the report's "Detail...On Format" event procedure:
    
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
        If Me.Section(0).BackColor = vbWhite Then
            Me.Section(0).BackColor = 12632256   ' gray
        Else
            Me.Section(0).BackColor = vbWhite
        End If
    End Sub
    

    Another newsgroup thread mentioned this as additional code for the Group Header's Format event procedure, and mentioned that you'd place it in the Page Header if no group header existed (I found it unnecessary to use at all in my case):

    
    Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
        Me.Detail.BackColor =  16777215  'Reset color
    End Sub