Bob Vance said:
Im tring to get a text box to change its back color if these conditions
are meet
ckbEmailWarn = True
tbAmountOwe = More than 1 Or less than 1
Isn't that the same as "tbAmountOwe not equal to 1"?
tbEmailState = 30 days old
If Me.ckbEmailWarn = 0 And Me.tbAmountOwe <1 Or >1 And Me.tbEmailState =
Date() <30
Or
Me.ckbEmailWarn = 0 And Me.tbAmountOwe <1 Or >1 And Me.tbEmailState = Null
Then
Me.tbWarning.BackColor = ED1C24
Else
Me.tbWarning.BackColor = FFFFFF
Your code, even allowing for improper syntax in places, doesn't seem to
correspond to the conditions you you stated. For example, you're checking
"ckbEmailWarn = 0", but that's equivalent to ckbEmailWarn = False, not True.
And you didn't say anything about tbEmailState being Null, but you have that
as an alternative in your code.
If you really want the specific conditions you stated, and only those, then
your code might be:
If (Me.ckbEmailWarn) _
And Me.tbAmountOwe <> 1 _
And DateDiff("d", Me.tbEmailState, Date()) >= 30 _
Then
Me.tbWarning.BackColor = ED1C24
Else
Me.tbWarning.BackColor = FFFFFF
End If
That is assuming that records should still meet your criteria if
tbEmailState is *more* than 30 days ago, not just if it's exactly 30 days
ago.
If you want to allow for Me.tbEmailState to be Null as well, you could amend
the code like this:
If (Me.ckbEmailWarn) _
And Me.tbAmountOwe <> 1 _
And ( _
DateDiff("d", Me.tbEmailState, Date()) >= 30 _
Or IsNull(Me.tbEmailState)) _
Then
Me.tbWarning.BackColor = ED1C24
Else
Me.tbWarning.BackColor = FFFFFF
End If
I don't know in what event(s) you intend to execute this code. Most lkely
would be the AfterUpdate events of any of the controls involved in the If
statement, and in the Current event of the form.