How to change text color based on date value?

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Hi.

I have a form that displays a datasheet, with one of the fields being
an expiration date. When the form loads and / or the data is changed,
I want to be able to change the text color of an entire row to red
when its expiration date is within one month of today's date. Can
someone point me to an example of how to do this?

Thanks!

-brian
 
To change formatting on a row-by-row basis you need to use conditional
formatting (Access 2000-2002). This feature allows you to specify upto 3
conditions and formatting options for when the each of the conditions is
met.

To use, select the control, click Format, Conditional Formatting. Check the
help for more details.

CF is somewhat limited in what it can do but it is useful for many
situations. Stephen Lebans has put together a sample database demonstrating
some ways to use Conditional Formatting:
http://www.lebans.com/conditionalformatting.htm

For a more robust solution Stephen Lebans also has code that provides more
conditional formatting features for forms - this also works in Access97:
http://www.lebans.com/formatbycriteria.htm

Other information on Conditional formatting:

ACC2000: How to Change the Color of the Control That Has Focus on a Form
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q210263

ACC2002: How to Programmatically Apply Conditional Formatting Settings to
All Form Controls
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q304104
 
Back
Top