Alternate lines gray

S

Stephm

Hi. I've created a report that looks a bit like an excel
spreadsheet: line after line of date, with the fields and
lines separated by a red line.

To make it easier to read across a line, I'm wondering if
I can somehow make alternate lines gray.

Any thoughts? Any suggestions of how to do it?

Thanks,
Stephanie
 
J

Jeff Conrad

Hi Stephanie,

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,
 
S

Stephm

Jeff,
Interesting! I've not used code on a report before (just
used the report wizard) so I'm excited to try. Thanks for
the reply! Cheers, Stephanie
-----Original Message-----
Hi Stephanie,

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
Bend, Oregon

Hi. I've created a report that looks a bit like an excel
spreadsheet: line after line of date, with the fields and
lines separated by a red line.

To make it easier to read across a line, I'm wondering if
I can somehow make alternate lines gray.

Any thoughts? Any suggestions of how to do it?

Thanks,
Stephanie


.
 
J

Jeff Conrad

You're welcome Stephanie, glad to help.
Good luck with your project.

--
Jeff Conrad
Access Junkie
Bend, Oregon

Stephm said:
Jeff,
Interesting! I've not used code on a report before (just
used the report wizard) so I'm excited to try. Thanks for
the reply! Cheers, Stephanie
-----Original Message-----
Hi Stephanie,

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
Bend, Oregon

Hi. I've created a report that looks a bit like an excel
spreadsheet: line after line of date, with the fields and
lines separated by a red line.

To make it easier to read across a line, I'm wondering if
I can somehow make alternate lines gray.

Any thoughts? Any suggestions of how to do it?

Thanks,
Stephanie
 

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

Top