473,395 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help with DateDiff and Conditional Formatting

Hello Again Access GURU's,

Need some help with Conditional Formatting and datediff. What I am trying
to do is the following:

I have three text boxes with dates in them and what I want to do is change
the background color if the date in the text box get within a certain date
range.

Date Range:
21 Days out Backcolor Green
14 Days out Backcolor Yellow
07 Days out Backcoor Red

Example:

textbox1 has date of 08/28/2006
textbox2 has date of 08/21/2006
textbox3 has a date of 08/14/2006

=DateDiff("d",[textbox1],Date()) <-- Gives me 21
=DateDiff("d",[textbox2],Date()) <-- Gives me 14
=DateDiff("d",[textbox3],Date()) <-- Gives me 07

How do i set the backcolor of the textbox to different colors listed above
given the date range

Thanks,

Argus
Aug 7 '06 #1
2 3620
Bob
OdAwG wrote:
Hello Again Access GURU's,

Need some help with Conditional Formatting and datediff. What I am trying
to do is the following:

I have three text boxes with dates in them and what I want to do is change
the background color if the date in the text box get within a certain date
range.

Date Range:
21 Days out Backcolor Green
14 Days out Backcolor Yellow
07 Days out Backcoor Red

Example:

textbox1 has date of 08/28/2006
textbox2 has date of 08/21/2006
textbox3 has a date of 08/14/2006

=DateDiff("d",[textbox1],Date()) <-- Gives me 21
=DateDiff("d",[textbox2],Date()) <-- Gives me 14
=DateDiff("d",[textbox3],Date()) <-- Gives me 07

How do i set the backcolor of the textbox to different colors listed above
given the date range

Thanks,

Argus
Hi -

Maybe something similar to:

Private Sub Form_Open(Cancel As Integer)
Dim x As Integer

x = 1 + DateDiff("d", Date, DateHold) \ 7
Me.DateHold.BackColor = IIf(x 4, 65408, Choose(x, 16777215, 255,
65535, 65408))

End Sub

Aug 8 '06 #2
I tried the following and it did not work, actually, nothing happened. What
am I doing wrong
If [Textbox1] < 7 And [Textbox1] 0 Then
[Textbox1].BackColor = RED
ElseIf [Textbox1] < 14 And [Textbox1] 7 Then
[Textbox1].BackColor = Yellow
ElseIf [Textbox1] < 24 And [Textbox] 14 Then
[Textbox1].BackColor = Green
End if

"OdAwG" <Od***@goneloose.comwrote in message
news:vK*******************@tornado.texas.rr.com...
Hello Again Access GURU's,

Need some help with Conditional Formatting and datediff. What I am trying
to do is the following:

I have three text boxes with dates in them and what I want to do is change
the background color if the date in the text box get within a certain date
range.

Date Range:
21 Days out Backcolor Green
14 Days out Backcolor Yellow
07 Days out Backcoor Red

Example:

textbox1 has date of 08/28/2006
textbox2 has date of 08/21/2006
textbox3 has a date of 08/14/2006

=DateDiff("d",[textbox1],Date()) <-- Gives me 21
=DateDiff("d",[textbox2],Date()) <-- Gives me 14
=DateDiff("d",[textbox3],Date()) <-- Gives me 07

How do i set the backcolor of the textbox to different colors listed above
given the date range

Thanks,

Argus


Aug 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bradley | last post by:
I have an A2000 database in which I have a continuous form with a tick box. There is also a text box with a conditional format that is based on the expression , if it's true then change the...
8
by: Dimitri Furman | last post by:
Given: Access 2002/2003 A subform in datasheet or continuous view, placed on a tab page (this last may or may not matter) Conditional formatting applied to some controls on the subform - format...
2
by: Von Bailey | last post by:
I have a form where the conditional formatting is set on some fields to bold if certain conditions are met. However, when the conditions are met some of the data that is to bold is either not...
5
by: Andrew Chanter | last post by:
Does anyone know a way you can use conditional formatting to create a banded style view as is commonly seen on the internet. (In othe words the first record appears on a gray background, the 2nd...
1
by: GGerard | last post by:
Hello Is there a way to use a variable in the Conditional Formatting of a Textbox? Example : I want the background of a textbox in a continuous form to change color when the value of...
2
by: jodyblau | last post by:
I'm not certain that what I am trying to do is possible; in any event I haven't been able to figure it out. Here is what I am trying to do: I have one table that has a list of cases I'm working...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
4
by: midlothian | last post by:
Hello, I have conditional formatting set up on a subform based on a calculated value in the underlying query. For instance, if Sales are >$1000, the query displays "Yes," otherwise it displays...
2
by: Kissi Asiedu | last post by:
Hello, I have three fields that holds expiration dates in a text box. I would like to be able to change the back color property to red when the expiration date is two weeks from the system date....
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.