totn Access

MS Access 2003: Conditionally change the background color of a text box on a Continuous Form

This MSAccess tutorial explains how to conditionally change the background color of a text box on a continuous form in Access 2003 (with screenshots and step-by-step instructions).

Question: In Microsoft Access 2003/XP/2000/97, how can I change the background color of a text box containing a date value on a Continuous Form? I would like to set the color individually on each record.

For example, if I had a field called Drivers_License_Expiration_Date, I would like to change the color of this field only on the records where the date is older than today. Can this be done?

Answer: This can be accomplished with Conditional Formatting.

To do this, open the form in design view and select the text box that you wish to conditionally format. In this example, we are selecting the Drivers_License_Expiration_Date.

Microsoft Access

Under the Format menu, select "Conditional Formatting".

Microsoft Access

Then select "Field Value Is" from the Condition1 combo box. Select "less than" from the next combo box and enter the following formula in the third field:

Now()

Microsoft Access

Next, select the formatting that you'd like to apply when this condition is met. We've chosen to change the background color to red when the Drivers_License_Expiration_Date is less than the current system date/time.

Click on the OK button.

Microsoft Access

Now, when you view your Continuous Form, the records whose Drivers_License_Expiration_Date is older than the current system date/time will display a red background.

You can apply this technique to change the forecolor of the text field as well.