I am trying to write a public function that will do conditional formatting, but I'm stuck. When I step through the code, it applys the correct forecolor, but to all the records; if the field is < then 0, all the records are red; if the field is >0, all the records are green...
Code:
Public Function redGreen(F As Form, fieldName As String)
Dim rs As Recordset
Set rs = F.Recordset
rs.MoveFirst
Do Until rs.EOF
If F(fieldName).Value > 0 Then
F(fieldName).ForeColor = vbGreen
ElseIf F(fieldName).Value < 0 Then
F(fieldName).ForeColor = vbRed
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Function