Setting background color depending on date

rexb

Registered User.
Local time
Today, 13:00
Joined
Oct 29, 2008
Messages
129
Hello,

Can somebody show me(i honestly don't know how to code this) on how to set the bacground color of the details section of the form depending on the date.

For example

If date entered is 05/05/09 - say this date is today the color of the details section pertaining to the records should be green and
any date before 04/20/09 should be green
If date entered is 04/20/09 - middle of the month the color should be orange and
any date before 04/05/09 should be orange
If date entered is 04/05/09 - a month after the color should be red and
any date after 04/05/09 should be red
the date is defined as text not date/time.
 
As long as you don't have more than 3 conditions plus the default, the simplest solution is Format/Conditional Formatting (on the ribbon in 2007).
 
You can use the DateAdd() function along with the Date() function in your calculations.

Also see:
Displaying specific dates
 
I would need some help on how to do this please. don't know how to code it
 
I don't understand your conditions, but this type of thing in Conditional Formatting:

[FieldName] = Date() OR [FieldName] < DateAdd("d", -15, Date())
 
Well it is the first form that opens and will display if transactions are pending or in progress. So what I would like is to have it color coded with reference to the date that it was requested. Say a request that came in today will be green up to 10 days and the request that came in after 10 days will be orange up until another 15 days. So that would be 25 days for orange any request that is still in that form after 25 days will be colored red. Hope this make sense. something like the attach. Thanks
 

Attachments

  • sample forms.JPG
    sample forms.JPG
    18.3 KB · Views: 201
Last edited:
How about conditions of:

[FieldName] > DateAdd("d", -10, Date())

for green

[FieldName] > DateAdd("d", -25, Date())

for orange, and a default of red.
 
How about conditions of:

[FieldName] > DateAdd("d", -10, Date())

for green

[FieldName] > DateAdd("d", -25, Date())

for orange, and a default of red.



so how do i code it?
 
Have you looked at Conditional Formatting?
 
I know the conditional formatting part. but what or which properties do i change. what format is that?
 
What Access version do you have?
 
Based on your question, I'm not sure you're looking at the conditional formatting I'm talking about. In 2003, with your form in design view, select the textbox you want to format, then Format/Conditional Formatting from the menu. Explore the settings in there.
 
Based on your question, I'm not sure you're looking at the conditional formatting I'm talking about. In 2003, with your form in design view, select the textbox you want to format, then Format/Conditional Formatting from the menu. Explore the settings in there.


sorry i just found that conditional formatting. don't really know my way around access that much. I tried it and it works well. So, if I have a continous form, how do I highlight the whole record?
 
You can apply the same format to all the textboxes, or you can put a big textbox behind all the others and apply the format to that. You'd set the back style of the other textboxes to transparent.
 
You can apply the same format to all the textboxes, or you can put a big textbox behind all the others and apply the format to that. You'd set the back style of the other textboxes to transparent.


thanks for all the help, very much appreciated.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom