Problem – I want the background color of a row to change each time a value changes from row to row – this will help visually group the data
Answer –
Create some custom code
Private _dateCount As Integer = 0
Private CurRowNumber as Integer = 0
Private ColorValue as String = “”
Function GetDateRowColor(ByVal previousVal As String, ByVal currentVal As String, MyRowNumber as Integer) As String
‘Check if this is a new row number…
If MyRowNumber <> CurRowNumber then
CurRowNumber = CurRowNumber + 1 ‘New row, so increment counter
If previousVal = currentVal Then
‘ Do nothing
Else
_dateCount = _dateCount + 1
End If
If _dateCount Mod 2 = 0 Then
ColorValue = “White”
Else
ColorValue = “Lavender”
End If
End If
Return ColorValue ‘Always return a value (for columns other than the first one)
End Function
Call the code in the row background setting property
=Code.GetDateRowColor(Previous(Fields!field_name.Value), Fields!field_name.Value, RowNumber(Nothing))