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 Formula Expression 1

Status
Not open for further replies.

awl

IS-IT--Management
Aug 2, 2001
136
US
I am looking for an appropriate formula in my Report to have the field [PRptDays] which is “a # of days”, displayed in Red if the field [PRptDays] has expired from the [DateOfExam] field. For example: The [DateOfExam] was 10/30/03 and the individual had 90 days [PRptDays] to gather his/her information together. If I open the report anytime within the 90 days, the number 90 will be displayed in black. However, if I open the report on 1 February 2004 or later, I want the # 90 displayed in red. I know how to format for the color red, it is just the expression. Thanks for any information.
 
Put code like this in the detail section's On Format event:
Code:
If (Date - [DateOfExam] > 90) Then
[PRptDays].ForeColor = vbRed
Else
[PRptDays].ForeColor = vbBlack
End If

Hoc nomen meum verum non est.
 
Thank you CosmoKramer. Most of the them work however, I have 3 instances where the color is black. I neglected to mention that the [PRptDays] could vary, but not exceed 90 days.

[DateOfExam] = 4/29/04 and [PRptDays] = 15, Expiration date should be 5/13/04
[DateOfExam] = 6/15/04 and [PRptDays] = 14, Expiration date should be 6/29/04
[DateOfExam] = 5/5/04 and [PRptDays] = 30, Expiration date should be 6/4/04

I went back to the original data to make sure the [DateOfExam] was a date field and that [PRptDays] were actual number fields.

A couple of examples that do convert to red:
[DateOfExam] = 5/5/03 and [PRptDays] = 15, Expiration date should be 5/20/03
[DateOfExam] = 2/12/04 and [PRptDays] = 15, Expiration date should be 2/27/04.

I'm not sure what the issue could be.


 
OK, I guess I misread the original post. So, you're using this as your statement and it is sometimes not working?:
Code:
If (Date - [DateOfExam] > [PRptDays]) Then
[PRptDays].ForeColor = vbRed
Else
[PRptDays].ForeColor = vbBlack
End If


Hoc nomen meum verum non est.
 
Thank you CosmoKramer for your professionalism. It works great!!!! Thanks. Curtis....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top