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

conditional formatting seems to defy logic

Status
Not open for further replies.

ebsdhen

Programmer
May 10, 2004
2
US
I have been developing a report based on a query, & I want to color a section of the report based on a specific criteria. The issue is: I have no issues w/a dual condition, but when I go into a triple condition, EVERYTHING gets colored out, as follows:
ADDED is a boolean field, BTW - & this is in the DETAIL FORMAT section.

If [ADDED] = True Then


If IsNull(Me.Preplan3) Then
If Me.Curplan3 <> Me.Preplan2 Then
If Me.Curplan3 <> Me.Preplan1 Then

Me.Curplan3.ForeColor = vbBlue
Me.Curcover3.ForeColor = vbBlue
Me.Curprem3.ForeColor = vbBlue
End If
End If
End If
End If
so I want to color the current plan 3 ONLY if it is added (not null). However, even if current plan3 is equal to previous plan1, it STILL colors the 3 controls blue. I have tried using AND sequences as well as nested IFs, but w/no luck. Can anyone pinpoint where the flaws are? Thanks in advance
 
Correct me if I'm wrong, but my understanding is that once you set the color, it will stay that color until it meets a
criteria to change it. Maybe try something like this:

Start by setting the forecolor to white, this way if the critiria is not met, it will default to white (or whatever color you want):
Me.Curplan3.ForeColor = vbWhite
Me.Curcover3.ForeColor = vbWhite
Me.Curprem3.ForeColor = vbWhite

Then check the critiria:

If [ADDED] = True Then
If IsNull(Me.Preplan3) Then
If Me.Curplan3 <> Me.Preplan2 Then
If Me.Curplan3 <> Me.Preplan1 Then
Me.Curplan3.ForeColor = vbBlue
Me.Curcover3.ForeColor = vbBlue
Me.Curprem3.ForeColor = vbBlue
End If
End If
End If
End If

Hope this helps,

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
That seems to have done the trick, and thanks! One would think that the default would be VBBLACK, ergo the change of default would be sufficient. How odd.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top