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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting The Forecolor

Status
Not open for further replies.

radder33

IS-IT--Management
Nov 26, 2009
66
DE
Morning

I am sure this will be astoundingly simple but I can't see whats going on.

I am running a report that has a simple number field to order the layout. I need specific rows of data to show a different tect colour. So if the row has group order number is one it needs to black anything else a different colour. I have put the following code on one field and it either sets them all to black or the other colour depending on what I set. Where am I going wrong?

Private Sub Report_Load()
If Me.GroupOrder = 2 Then
Me.Total.ForeColor = RGB(0, 0, 0)
Else
Me.Total.ForeColor = RGB(153, 53, 153)
End If
End Sub

Thanks in advance.
 
You are not doing anything wrong, however, that is the expected result. There is really only one set of controls and the rows are a "paint" of them. So if you change the properties all rows change. So on a continous form the normal way is conditional formatting. This is limited to 3 conditions and a default. You only need 2 colors so no problem.

It is also possible in the detail section paint event. The paint event happens before the data is painted to the screen. Basically conditional format does this for you.
Example
Private Sub Detail_Paint()
If Me.UnitPrice > 15 Then
Me.UnitPrice.ForeColor = vbRed
Else
Me.UnitPrice.ForeColor = vbBlue
End If
End Sub

This can work, but it for some reason is unreliable especially if the control is calculated.
 
MajP paint worked a treat thats great thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top