Color a rectangle box background based on a date

M

Mark

I have a rectangle that I would like to change the background color based on
a date. For example:

I have a TextBox called CPR. This has stores the date of a CPR class. I
have drawn a rectangle beside the box. I would like to have the background
color change based on the date in the field CPR.

Say the CPR Training expires in 1 year I would like the box to remain green
until it is within two months of expiration, when this occurs I would like
the rectangle to turn yellow and then when the training date exceeds the 1
year mark, I would like to box to turn red.

any help would be appreciated. TIA

Mark
 
I

Ian Baker

Mark
If you are referring to 1 rectangle and not many all over a form then place
this code (subsituting the MyRectangle with the name of your rectangle) in
the OnCurrent event of your form and also in the AfterUpdate event of the
CPR control:

Select Case Date - Me!CPR
Case Is > 365
Me!MyRectangle.BackColor = 255
Case Is > 305
Me!MyRectangle.BackColor = 65535
Case Else
Me!MyRectangle.BackColor = 65408
End Select

Note that this is simplistic as it only uses a number of days (i.e. 365 = 1
year and 305 = 10 months) and not adding months the the CPR date.

Hope this helps
--
Regards

Ian Baker
Jackaroo Developments Pty Ltd
Download Jackaroo (an IT Help Desk application) at Web:
http://jackaroo.net.au
| I have a rectangle that I would like to change the background color based
on
| a date. For example:
|
| I have a TextBox called CPR. This has stores the date of a CPR class. I
| have drawn a rectangle beside the box. I would like to have the
background
| color change based on the date in the field CPR.
|
| Say the CPR Training expires in 1 year I would like the box to remain
green
| until it is within two months of expiration, when this occurs I would like
| the rectangle to turn yellow and then when the training date exceeds the
1
| year mark, I would like to box to turn red.
|
| any help would be appreciated. TIA
|
| Mark
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top