Conditional Formatting & transparent colours

James Pye

James
Local time
Today, 18:52
Joined
Jan 17, 2010
Messages
10
Hi,

I have a report that summarises teams totals in a dreamteam competition, and have used the following code to alternate the background colour of each row:

Dim blnalternate As Boolean

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If blnalternate Then
Detail.BackColor = 15066597
Else
Detail.BackColor = 16777215
End If

blnalternate = Not (blnalternate)

End Sub

What I want to be able to do is change the text colour of 2 controls to match the above, if they haven't paid. The controls are txtTeam & txtManager, and Paid is in the query, qsel_SummaryPts that the report is based on.

Many thanks
 
After a bit of research I managed to do what I wanted by updating the above code to:

Dim blnalternate As Boolean

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If blnalternate Then
Detail.BackColor = 15066597
If Paid = False Then
Me.Team.BackColor = 15066597
Me.Team.ForeColor = 15066597
Me.Manager.BackColor = 15066597
Me.Manager.ForeColor = 15066597
ElseIf Paid = True Then
Me.Team.BackColor = 15066597
Me.Team.ForeColor = vbBlack
Me.Manager.BackColor = 15066597
Me.Manager.ForeColor = vbBlack
End If
Else
Detail.BackColor = 16777215
If Paid = False Then
Me.Team.BackColor = 16777215
Me.Team.ForeColor = 16777215
Me.Manager.BackColor = 16777215
Me.Manager.ForeColor = 16777215
ElseIf Paid = True Then
Me.Team.BackColor = 16777215
Me.Team.ForeColor = vbBlack
Me.Manager.BackColor = 16777215
Me.Manager.ForeColor = vbBlack
End If
End If

blnalternate = Not (blnalternate)
End Sub

If this seems longwinded and someone knows how to do it in a better way, thoughts would be appreciated.
 

Users who are viewing this thread

Back
Top Bottom