How do I shade every other row in an Access report?

G

Guest

I have created a report in access and want to shade every other row for
better visibility. I am currently using Access 97.
 
F

fredg

I have created a report in access and want to shade every other row for
better visibility. I am currently using Access 97.

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.
 
A

AlCamp

I use...

Option Compare Database
Option Explicit
Dim fshade As Integer
----------------------------------
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Const COLOR_SHADE = &HECECEC
Const DS_INVISIBLE = 5
If fshade = False Then
Me.DrawStyle = DS_INVISIBLE
Me.Line (0, 0)-(7034, Me.Section(0).Height), COLOR_SHADE, BF
End If
fshade = Not fshade
End Sub
------------------------------------------------
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
fshade = True
End Sub
-----------------

Adjust the Me.Line() and COLOR_SHADE to suit.
I hope I'm not violating any copyright... I got this originally from a Ken
Getz Access 2.0 book.
hth
Al Camp
 
F

Fons Ponsioen

To answer your question here is an excert from an earlier
posting by Marshall Barton:
It's simpler using code.
Without code, if you're using A2K or later, First, add a
text box named txtLineCtr, make it invisible and set its
expression to =1.
Make the BackStyle of all of your current controls
Transparent.
Then add another text box (the same size as the entire
detail section) and use The Format - Send To Back menu
item to put it behind all the other controls. Now you can
set tis text box's Conditional Formatting - Expression Is
txtLineCtr Mod 2 = 0
with your selected background color.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top