Different color the rows

  • Thread starter Thread starter Dragan
  • Start date Start date
D

Dragan

How to make report so that the rows have different color?

For example:

First row have a off-white background color and second row have a white
background color at so on.

Thanks
 
I use this method, there may be many other ways of doing this.
This code is the very basic function (set up for Detail Section graybar),
but with tweaking... this method is very flexible, allowing for graybar
width adjustment, gray every 3rd record, or 4th record, graybar color...
etc. (Use your own names)
It's from my old Access 2.0 "bible" Access 2.0 How To CD by Ken Getz. A
real classic!

Option Compare Database
Option Explicit
Dim fshade As Integer

Private Sub Detail1_Print(Cancel As Integer, PrintCount As Integer)
Const ColorShade = &HECECEC
Const Invisible = 5
If fshade Then
Me.DrawStyle = Invisible
Me.Line (0, 0)-(Me.Width, Me.Section(0).Height), ColorShade, BF
End If
fshade = Not fshade
End Sub

Private Sub PageHeader0_Format(Cancel As Integer, FormatCount As Integer)
fshade = False
End Sub

Also, I found
http://archive.baarns.com/access/faq/ad_reprt.asp#4

hth
Al Camp
 
How to make report so that the rows have different color?

For example:

First row have a off-white background color and second row have a white
background color at so on.

Thanks

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 = 12632256 'Reset color to Grey so that the
first detail line will become white

Change the colors as needed.
 
Back
Top