Problem with Conditional Formatting

Local time
Tomorrow, 04:00
Joined
Jul 12, 2006
Messages
70
Good day!

I placed the code below on the On load event of one of my forms. My problem is it doesn't work. The [Class] field are all highlighted in red even if the value is not "CRITICAL".


Private Sub Form_Load()

If Me.[UnitClass].Value = "CRITICAL" Then
Me.[Class].BackColor = 255
End If
If Me.[UnitClass].Value = "PUSH" Then
Me.[Class].BackColor = 16711680
End If
If Me.[UnitClass].Value = "SELLING" Then
Me.[Class].BackColor = 65535
End If

End Sub


Thanks in advance!

Sheila
 
Iwould do it on the current even,and use select case rather than If's. I have added a default option as well

Code:
Private Sub Form_Current()

Select Case Me.[UnitClass]
Case Is = "CRITICAL"
    Me.[Class].BackColor = 255
Case Is = "PUSH"
    Me.[Class].BackColor = 16711680
Case Is = "SELLING"
    Me.[Class].BackColor = 65535
Case Else
    Me.[Class].BackColor = 16777215 ' or what ever you want when it is 'none of the above'
End Select

End Sub

HTH

Peter
 

Users who are viewing this thread

Back
Top Bottom