Alternating color based on a group in 2007

M

Michelle

I have a report that I woul like to alternate the color for each group in
2007 I thougth I knew how to do this but it is not working for me at all.
Any suggestions
 
A

Allen Browne

Are you trying to alternate the color for each record?

If so, open the report in design view, select the Detail section, and set
the Alternate Back Color property.

If you want to alternate the color for entire groups (not for each record),
you could do that with a combination of Running Sum and either Conditional
Formatting or Format event:

1. Place a text box in your Group Header, and give it these properties:
Control Source =1
Running Sum Over All
Format General Number
Visible No
Name txtGroupCount

2. Set the On Format event of the Detail section to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.
Set up the routine like this, replacing the vbBlue and vbRed with the RGB
colors you want:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim lngColor As Long

If FormatCount = 1 Then
lngColor = IIf(Me.txtGroupCount Mod 2 = 0, vbBlue, vbRed)
If Me.Section(acDetail).BackColor <> lngColor Then
Me.Section(acDetail).BackColor = lngColor
End If
End If
End Sub
 

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