Font colors in a report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to have my records in the detail of my report be alternate colors. One line black the next line red for easy reading. Can I do that? If so, how? I am using Access 2002.
 
Found this in a previous post:

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.


HTH,
Jake
 
AD said:
I would like to have my records in the detail of my report be alternate colors. One line black the next line red for easy reading. Can I do that? If so, how? I am using Access 2002.


Red? Red is not easy to read.

You can get that effect with:

If Me.textbox1.ForeColor <> vbRedThen
Me.textbox1.ForeColor = vbRed
Me.textbox2.ForeColor = vbRed
. . .
Else
Me.textbox1.ForeColor = vbBlack
Me.textbox2.ForeColor = vbBlack
. . .
End If

It's more common to change the background color to a light
gray and leave the forground color black. Set all of the
label and text box control's BackStyle to Transparent, then
set the detail section's BackColor:

If Me.Section(0).BackColor <> vbWhite Then
Me.Section(0).BackColor = vbWhite
Else
Me.Section(0).BackColor = RGB(228,228,228)
End If
 
I would like to have my records in the detail of my report be alternate colors. One line black the next line red for easy reading. Can I do that? If so, how? I am using Access 2002.

Jake gave you my code to alternate the background color of the detail
section, but I think you wanted to alternate the fore color of each
control in the secton. Is that correct?

If so...
In the Detail Format event, code:

Dim c As Control
For Each c In Me.Section(0).Controls
If TypeOf c Is TextBox Or TypeOf c Is Label Then
If c.ForeColor = vbBlack Then
c.ForeColor = vbRed
Else
c.ForeColor = vbBlack
End If
End If
If TypeOf c Is Line Then
If c.BorderColor = vbBlack Then
c.BorderColor = vbRed
Else
c.BorderColor = vbBlack
End If
End If
Next c

Note that the Line has a bordercolor property not a forecolor
property.
If you have other printable control's (combo box, rectangle, etc. add
them to the typeof list as needed.
 
Thanks, that was very helpful. I also have a subreport and this formatting wasn't applied to it. I tried putting it in the detail section of the subreport and that didn't work. How do I apply it to the subreport?
 
Back
Top