Formatting Detail Backcolor

  • Thread starter Thread starter Barry F
  • Start date Start date
B

Barry F

I am trying to make a detail report easier to read by
alternating the backcolor. Here is what I have:
Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
Dim cnt As Integer
cnt = 1
If Me.FormatCount = 1 Then
cnt = cnt + 1

If cnt Mod 2 = 0 Then
Me.Section(acDetail).BackColor = 12632256

Else
Me.Section(acDetail).BackColor = 16777215

End If
End If
End Sub

I know I am missing something as it prints with just the
one backcolor.
Any help is appreciated.
Barry F
 
I picked this up from one of the MVP's. This shades every other lin
grey.

Good Luck

Make sure the BackStyle of each control is Transparent.

Code the Detail Format event:

If Me.Section(0).BackColor = vbWhite Then
Me.Section(0).BackColor = 12632256 ' gray
Else
Me.Section(0).BackColor = vbWhite
End If

====
If you wish each page to start with a white row, code the Page Header
Format event:

Me.Detail.BackColor = 16777215 'Reset color

Change the colors as needed.

If you wanted to do every nth row gray, then it is a little mor
complex.
Add a control to the detail section.
Set its control source to =1 and
its running sum to overall and
its visible to No (False) and
its name to txtCountLines

Code the Detail Format event:

If Me.txtCountLines Mod 3 = 0 Then
Me.Section(0).BackColor = 12632256 'gray
Else
Me.Section(0).BackColor = vbWhite
End If

Change the 3 in the first line to 4 for every fourth line, etc
 
Back
Top