Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field Colour Format on criteria

Status
Not open for further replies.

shadowfather

Technical User
May 20, 2005
5
GB
I have a report that shows a number field with days outstanding. I want it to show the results in differant colours depending on days outstanding. i.e

< 30 Black
>=30 to < 60 Green
>=60 to < 90 Blue
>=90 to < 120 Yellow
> 120 Red

I can get it to work for one colour, but how do I do it for multiple criteria?

I used the following:-


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me![Days outstanding] < 30 Then
Me![Days outstanding].ForeColor = vbRed
Else
Me![Days outstanding].ForeColor = vbBlack
End If
End Sub
 
Use Select Case or If / Else / ElseIf

Simon Rouse
 
Hi,

Try something along these lines:
Hi,

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me![Days outstanding] > 120 Then
Me![Days outstanding].ForeColor = vbRed
Else
if Me![Days outstanding] < 120 And >= 90 then
Me![Days outstanding].ForeColor = Yellow
Else
if Me![Days outstanding] < 90 And >= 60 then
Me![Days outstanding].ForeColor = blue
Else
if Me![Days outstanding] < 60 And >= 30 then
Me![Days outstanding].ForeColor = Green
Else
Me![Days outstanding].ForeColor = Black

End if

End if
End if
End If
End Sub

M-.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top