Alternate background color

  • Thread starter Thread starter SF
  • Start date Start date
S

SF

Hi,

I have a report that I want to change the background color into 3 alternate
colors eg White, gray and dark gray. How to archeive that?

SF
 
Try this code in the On Format event of the detail section. Read the
comments regarding the new text box in your detail section

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'this code assumes there is a text box in the detail section
' Name: txtCountSection
' Control Source: =1
' Running Sum: Over Group
' Visible: No (optional)
Select Case Me.txtCountSection Mod 3
Case 1
Me.Detail.BackColor = vbWhite
Case 2
Me.Detail.BackColor = 12632256
Case 0
Me.Detail.BackColor = 8421504
End Select
End Sub
 
SF said:
I have a report that I want to change the background color into 3 alternate
colors eg White, gray and dark gray. How to archeive that?


Add code to the detail section's Format or Print event
procedure. The general idea is along these lines:

With Me.Section(0)
If .BackColor = vbWhite Then
.BackColor = RGB(230,230,230)
ElseIf .BackColor = RGB(230,230,230) Then
.BackColor = RGB(160,160,160)
Else
.BackColor = vbWhite
End If
End With

To make the first line white, use that report header or a
group header section Format evnt to initialize the color:
Me.Section(0).BackColor = vbRed 'anything other than white
 
Back
Top