Expression to change color of text accordinng to date (1 Viewer)

saskurja7

New member
Local time
Today, 03:28
Joined
Jun 26, 2013
Messages
3
I am attempting to create an expression that will change the font to red if it is an overdue date. It will be on a form with the records showing.

My datebase is for entering, changing, and searching for information dealing with orientation dates, contacts, and associations. My data sheet holds the company name, employee name, date of orientation, due date (orientations are completed annually), contact employee, and status. I would like the date, when opening the form, to show red if it is past due. If you are nice enough, maybe help me figure out how to create an expresion to return the status as "Current" or "Overdue", as I am still unsure which method I want to use.

Any guidance would be very helpful. I am a little new and trying to teach myself all of the stuff. If I need to give more info to help you with this, please let me know.

Thanks!!
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:28
Joined
Feb 19, 2013
Messages
16,601
you need to use the conditional formatting property for the control.

Assuming you have only two 'states' current and overdue and your control is called DueDate do the following:

In form design view, clcik on the DueDate control andse the text formatting to set the back colour of DueDate to say green.

Then under the fomatting tab, select conditional formatting and click on new rule (assuming you are using 2007/10 but similar for 2003)

Set the following:
FieldValue Is
Less Than
Date()

Then select the format you want - e.g. set back colour to red, font colour to white and font weight to bold

Click OK

This will turn all due dates earlier than today to white characters on red background

If you want to then show all due dates which are due in the next week then do the following

Add a new rule (which needs to be after the first rule) and set as follows:

FieldValue Is
Less Than
Date()+7

Then select the format you want - e.g. set back colour to orange

All due dates that are between today and the next 7 days will now be orange

The order of rules are important because once a rule has been satisfied it is not changed by a subsequent rule so if you were to reverse the two rules above a duedate of yesterday would be satisfied as less than date()-7 (orange) and would not subseqently be updated by less than date() (red)
 

Users who are viewing this thread

Top Bottom