Is there an easy way of doing alternating colors in the details section of a report. This isn't critical, it would just be nice and if there is an easy way of doing, that would be great!
Access 2007 has an option to change the back colour in the detail section (Alternate Back Colour).
For earlier versions you can do your own code. Take a look here.
I prefer to just toggle a boolean like this:
Code:
Dim blCol As Boolean
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If blCol Then
Me.Detail.BackColor = 15263976
Else
Me.Detail.BackColor = 14811135
End If
blCol = Not blCol
End Sub
Fyi: I prefer doing it without code... in the report's module so you can still have a "light" report (i.e. a report without code in the report's module).
You can use a textbox and Conditional Formatting:
1. Drop the textbox onto the section and send it to the back. Say we call the textbox txtHLite
2. Set the Back Style property to Normal
3. Set the Control Source property to =1 and the Running Sum property to Over All (but if you have a grouping set, run it Over Group)
4. Open Conditional Formatting and in the 1st (and only condition) select Expression Is and put ([txtHLite] Mod 2)=0 as the condition
5. In the conditional formatting dialog set the forecolor and backcolor of Condition 1 to the same color, so grey for example
6. In the conditional formatting dialog set the forecolor and backcolor of the Default Condition both to White
7. Ok it and it's done!
The other advantage to this method is you can (obviously) control the height and width of the highlight.