Here is a past post of mine on this subject which should help:
I know of a couple of ways to do this. I use one or the other
method depending upon the need.
First Way: Full Detail Section colored
(Learned from FredG I think)
Watch out for possible line wrapping here!
1. Code the Detail part of your report like this:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Section(0).BackColor = vbWhite Then
Me.Section(0).BackColor = 15724527
Else
Me.Section(0).BackColor = vbWhite
End If
End Sub
2. Now Code the Page Header part of your report like this
to start a new page with white (I think that's correct).
Private Sub PageHeader_Format(Cancel As Integer, FormatCount As Integer)
Me.Detail.BackColor = 16777215
End Sub
By the way, the color grey I have listed there is a real
light grey. Change to whatever you like.
What this will do is fill the entire detail section with
alternating color. This works fine on some reports, but
for other reports where I have a very small detail section
width-wise it's a little much. So I use a different approach.
Second Way: Small Width Detail section
1. Use the rectangle tool to create a box in your detail
section. Set the following properties for it:
--Name BoxShade
--Visible No
--Back Style Normal
--Back Color 15724527
--Special Effect Flat
--Border Style Transparent
2. Now resize the box to just cover the area of detail you
want to have colored.
3. No go up to to the Format menu and select "Send To
Back". This will put the box behind the other controls in
the Detail section.
4. I usually have an option control on a form that has two
options: "No Shading" and "Shade Every Other Line". I have the
default as No Shading (0 in the option group). I then code
the detail section of the report like this:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [Forms]![frmNameOfMyForm]![ShadeOption] = 1 Then
If Me.boxShade.Visible = False Then
Me.boxShade.Visible = True
Else
Me.boxShade.Visible = False
End If
Else
Me.boxShade.Visible = False
End If
End Sub
The shading will now appear on every other row, but just
where I want it to shade. By the way, I still use the
option control on the form for the first example above,
but didn't include the code. You should be able to see how
to code it either with an option control on a form or
without by following the two examples.
And here are some Microsoft KB articles as well:
http://support.microsoft.com/?id=114086
http://support.microsoft.com/?id=210392
http://support.microsoft.com/?id=288154
Hope that gives you some ideas,
--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html
in message:
hello,
Is it possible to alternate the colour of the detail section for each line?
I hope that question is clear, if not what im looking for is the first line
in the detail section to have a white background, 2nd line to be grey, 3rd to
be white etc....