Hi Darren
A simple syntax problem. Try this:-
Private Sub Form_Current()
If Me.Fee.Value <> Me.SuggFee.Value Then
Me.Fee.BackColor = 255
Me.Fee.ForeColor = 16777215
Else
Me.Fee.BackColor = -2147483643
Me.Fee.ForeColor = -2147483640
End If
End Sub
The keyword "And" in VBA has a specific meaning, and does not match its usage in English, or in SQL. In VBA, it never means "do this as well", which is how you are using it here. It is used as a logical expression, testing whether two expressions both evaluate to Boolean True.
If I'm right about how Access was interpreting your code, the background colour was going black (value 0) - that is, (255 And (Me.Fee.ForeColor = 16777215)), or in English, if Forecolour is 16777215, then 255 (which counts as true) and true would be -1, but since you are setting that forecolour, then it is probably different, so you get True And False which is false, or 0, which is black.
Complicated, because you have effectively mixed integers and booleans; booleans have both a True/False value and a numeric (-1/0) value.
Hope that helps!
Richard
|