473,800 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3654
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(Cance l As Integer)
Dim x As Integer

x = 1 + DateDiff("d", Date, DateHold) \ 7
Me.DateHold.Bac kColor = 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***@goneloos e.comwrote in message
news:vK******** ***********@tor nado.texas.rr.c om...
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
3144
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 background colour. In A2000 it works great, but in A2003 the background doesn't always change and when it does it only changes when the record looses the focus. Any way around this? Is it a bug? Or have they "improved" it?
8
12058
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 expressions are the same for all controls Under some undetermined circumstances, when such subform is displayed, the controls on the subform start to visibly flicker, the cursor in the subform stops blinking, and CPU utilization goes to 100%....
2
2969
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 showing or only part of the data in the field displays (i.e. it will display the last name but not the first name or it will display neither). When the conditional formatting is removed it displays all the data as it should be display so the data...
5
8977
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 on white, the third on gray etc etc.) I could write an expression based on the odd/even status of the primary key but this wont work when sorting and filtering is applied. Any suggestions gratefully received.
1
5021
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 "MyField1" is True. No problem, I just need to write "Expression is" and " = -1 "
2
2355
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 on. I have a second table that contains a list of tasks to be performed and relates to the Case_List through a Case_ID. So currently, I can bring up a form that has a list of all my cases, I can then select a case and it opens a new form that...
8
8514
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 perfectly. However, I have code that runs under the ON CLICK event. The code changes the focus to other controls, which means the conditional formatting is no longer displayed. This part makes sense to me. Here's what doesn't make sense. The last...
4
13204
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 "No." The conditional formatting is set up to read the 'Yes' or 'No' value and color the text accordingly. I have an event in the subform that allows users to update the sales. It actually runs an update query behind the scenes. What I want to...
2
1497
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. The records will be populated in a form by way of a query. Please help.
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10273
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10250
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.