A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Conditional formats based on time



 
 
Thread Tools Display Modes
  #1  
Old October 24th, 2008, 06:50 PM posted to microsoft.public.access
Very Basic User
external usenet poster
 
Posts: 140
Default Conditional formats based on time

Hello,

I'm trying to have a cell in a report turn red if the item is still active
in a data base. In other words. I have an action register. for my report, I
filter out everything that is not "in progress" I have a "Date entered"
field. What I would like is if the item is still "in progress" 60 days after
teh "date entered" I would like the report line to turn red.

Any help would be appreciated!
--
Thank you for your time!
John
  #2  
Old October 24th, 2008, 09:43 PM posted to microsoft.public.access
Adam Milligan
external usenet poster
 
Posts: 51
Default Conditional formats based on time

In the "on format" event of the detail section enter something along the
lines of the following code:

If Me.[DateEntered] Date()-60 then

me.detail.backcolor = 255

end if


"Very Basic User" wrote:

Hello,

I'm trying to have a cell in a report turn red if the item is still active
in a data base. In other words. I have an action register. for my report, I
filter out everything that is not "in progress" I have a "Date entered"
field. What I would like is if the item is still "in progress" 60 days after
teh "date entered" I would like the report line to turn red.

Any help would be appreciated!
--
Thank you for your time!
John

  #3  
Old October 24th, 2008, 09:49 PM posted to microsoft.public.access
TONGO
external usenet poster
 
Posts: 4
Default Conditional formats based on time

I DANT SPEAK ENGLECH I M SPEAK FRENCH
  #4  
Old October 24th, 2008, 11:09 PM posted to microsoft.public.access
Ken Sheridan
external usenet poster
 
Posts: 3,433
Default Conditional formats based on time

A few problems with that:

1. Its better to use the DateAdd function than simple date arithmetic,
which places reliance on the implementation, something good programming
practice should avoid.

2. Once the BackColor property is set to red it will stay that way for
subsequent rows unless reset to white.

3. To make the whole row red its also necessary to set the BackColor
property of each of its controls as well as that of the section.

So the code for the detail section's Format event procedure would be:

Dim sec As Section
Dim ctrl As Control

Set sec = Me.Section(acDetail)

If Me.[Date Entered] = DateAdd("d",-60,VBA.Date) Then
sec.BackColor = vbRed
For Each ctrl In sec.Controls
ctrl.BackColor = vbRed
Next ctrl
Else
sec.BackColor = vbWhite
For Each ctrl In sec.Controls
ctrl.BackColor = vbWhite
Next ctrl
End If

Ken Sheridan
Stafford, England

"Adam Milligan" wrote:

In the "on format" event of the detail section enter something along the
lines of the following code:

If Me.[DateEntered] Date()-60 then

me.detail.backcolor = 255

end if


"Very Basic User" wrote:

Hello,

I'm trying to have a cell in a report turn red if the item is still active
in a data base. In other words. I have an action register. for my report, I
filter out everything that is not "in progress" I have a "Date entered"
field. What I would like is if the item is still "in progress" 60 days after
teh "date entered" I would like the report line to turn red.

Any help would be appreciated!
--
Thank you for your time!
John


  #5  
Old October 24th, 2008, 11:19 PM posted to microsoft.public.access
Adam Milligan
external usenet poster
 
Posts: 51
Default Conditional formats based on time

Ken-

Thanks for chiming on on that one. Those are things I would have
(obviously) run into once I tested it and then smacked my forehead and said
"duh!". It's a lot more difficult to just throw code out to people in need
and get it right the first time. I really respect the patience and
knopwledge you MVPs show everyone around here. Thanks.

Adam Milligan

"Ken Sheridan" wrote:

A few problems with that:

1. Its better to use the DateAdd function than simple date arithmetic,
which places reliance on the implementation, something good programming
practice should avoid.

2. Once the BackColor property is set to red it will stay that way for
subsequent rows unless reset to white.

3. To make the whole row red its also necessary to set the BackColor
property of each of its controls as well as that of the section.

So the code for the detail section's Format event procedure would be:

Dim sec As Section
Dim ctrl As Control

Set sec = Me.Section(acDetail)

If Me.[Date Entered] = DateAdd("d",-60,VBA.Date) Then
sec.BackColor = vbRed
For Each ctrl In sec.Controls
ctrl.BackColor = vbRed
Next ctrl
Else
sec.BackColor = vbWhite
For Each ctrl In sec.Controls
ctrl.BackColor = vbWhite
Next ctrl
End If

Ken Sheridan
Stafford, England

"Adam Milligan" wrote:

In the "on format" event of the detail section enter something along the
lines of the following code:

If Me.[DateEntered] Date()-60 then

me.detail.backcolor = 255

end if


"Very Basic User" wrote:

Hello,

I'm trying to have a cell in a report turn red if the item is still active
in a data base. In other words. I have an action register. for my report, I
filter out everything that is not "in progress" I have a "Date entered"
field. What I would like is if the item is still "in progress" 60 days after
teh "date entered" I would like the report line to turn red.

Any help would be appreciated!
--
Thank you for your time!
John


  #6  
Old October 30th, 2008, 12:00 PM posted to microsoft.public.access
Very Basic User
external usenet poster
 
Posts: 140
Default Conditional formats based on time

Now if I only wanted to turn the date red, is there a simple conditional
formatting line that I could use?
--
Thank you for your time!
John


"Adam Milligan" wrote:

Ken-

Thanks for chiming on on that one. Those are things I would have
(obviously) run into once I tested it and then smacked my forehead and said
"duh!". It's a lot more difficult to just throw code out to people in need
and get it right the first time. I really respect the patience and
knopwledge you MVPs show everyone around here. Thanks.

Adam Milligan

"Ken Sheridan" wrote:

A few problems with that:

1. Its better to use the DateAdd function than simple date arithmetic,
which places reliance on the implementation, something good programming
practice should avoid.

2. Once the BackColor property is set to red it will stay that way for
subsequent rows unless reset to white.

3. To make the whole row red its also necessary to set the BackColor
property of each of its controls as well as that of the section.

So the code for the detail section's Format event procedure would be:

Dim sec As Section
Dim ctrl As Control

Set sec = Me.Section(acDetail)

If Me.[Date Entered] = DateAdd("d",-60,VBA.Date) Then
sec.BackColor = vbRed
For Each ctrl In sec.Controls
ctrl.BackColor = vbRed
Next ctrl
Else
sec.BackColor = vbWhite
For Each ctrl In sec.Controls
ctrl.BackColor = vbWhite
Next ctrl
End If

Ken Sheridan
Stafford, England

"Adam Milligan" wrote:

In the "on format" event of the detail section enter something along the
lines of the following code:

If Me.[DateEntered] Date()-60 then

me.detail.backcolor = 255

end if


"Very Basic User" wrote:

Hello,

I'm trying to have a cell in a report turn red if the item is still active
in a data base. In other words. I have an action register. for my report, I
filter out everything that is not "in progress" I have a "Date entered"
field. What I would like is if the item is still "in progress" 60 days after
teh "date entered" I would like the report line to turn red.

Any help would be appreciated!
--
Thank you for your time!
John


  #7  
Old October 30th, 2008, 07:10 PM posted to microsoft.public.access
Adam Milligan
external usenet poster
 
Posts: 51
Default Conditional formats based on time

Stealing Ken's code below try this...

If Me.[Date Entered] = DateAdd("d",-60,VBA.Date) Then
me.[Date Entered].forecolor = vbRed
Else
me.[Date Entered].forecolor= vbBlack
End If


P.S. I find it very useful to NEVER put spaces in my field names
"Very Basic User" wrote:

Now if I only wanted to turn the date red, is there a simple conditional
formatting line that I could use?
--
Thank you for your time!
John


"Adam Milligan" wrote:

Ken-

Thanks for chiming on on that one. Those are things I would have
(obviously) run into once I tested it and then smacked my forehead and said
"duh!". It's a lot more difficult to just throw code out to people in need
and get it right the first time. I really respect the patience and
knopwledge you MVPs show everyone around here. Thanks.

Adam Milligan

"Ken Sheridan" wrote:

A few problems with that:

1. Its better to use the DateAdd function than simple date arithmetic,
which places reliance on the implementation, something good programming
practice should avoid.

2. Once the BackColor property is set to red it will stay that way for
subsequent rows unless reset to white.

3. To make the whole row red its also necessary to set the BackColor
property of each of its controls as well as that of the section.

So the code for the detail section's Format event procedure would be:

Dim sec As Section
Dim ctrl As Control

Set sec = Me.Section(acDetail)

If Me.[Date Entered] = DateAdd("d",-60,VBA.Date) Then
sec.BackColor = vbRed
For Each ctrl In sec.Controls
ctrl.BackColor = vbRed
Next ctrl
Else
sec.BackColor = vbWhite
For Each ctrl In sec.Controls
ctrl.BackColor = vbWhite
Next ctrl
End If

Ken Sheridan
Stafford, England

"Adam Milligan" wrote:

In the "on format" event of the detail section enter something along the
lines of the following code:

If Me.[DateEntered] Date()-60 then

me.detail.backcolor = 255

end if


"Very Basic User" wrote:

Hello,

I'm trying to have a cell in a report turn red if the item is still active
in a data base. In other words. I have an action register. for my report, I
filter out everything that is not "in progress" I have a "Date entered"
field. What I would like is if the item is still "in progress" 60 days after
teh "date entered" I would like the report line to turn red.

Any help would be appreciated!
--
Thank you for your time!
John

  #8  
Old October 30th, 2008, 07:36 PM posted to microsoft.public.access
Very Basic User
external usenet poster
 
Posts: 140
Default Conditional formats based on time

This is exactly what I need, I also figured out your original code
understanding now that [Date Entered] needed to be typed exactly as my field
was written. Thank you very much for your help and support!
--
Thank you for your time!
John


"Adam Milligan" wrote:

Stealing Ken's code below try this...

If Me.[Date Entered] = DateAdd("d",-60,VBA.Date) Then
me.[Date Entered].forecolor = vbRed
Else
me.[Date Entered].forecolor= vbBlack
End If


P.S. I find it very useful to NEVER put spaces in my field names
"Very Basic User" wrote:

Now if I only wanted to turn the date red, is there a simple conditional
formatting line that I could use?
--
Thank you for your time!
John


"Adam Milligan" wrote:

Ken-

Thanks for chiming on on that one. Those are things I would have
(obviously) run into once I tested it and then smacked my forehead and said
"duh!". It's a lot more difficult to just throw code out to people in need
and get it right the first time. I really respect the patience and
knopwledge you MVPs show everyone around here. Thanks.

Adam Milligan

"Ken Sheridan" wrote:

A few problems with that:

1. Its better to use the DateAdd function than simple date arithmetic,
which places reliance on the implementation, something good programming
practice should avoid.

2. Once the BackColor property is set to red it will stay that way for
subsequent rows unless reset to white.

3. To make the whole row red its also necessary to set the BackColor
property of each of its controls as well as that of the section.

So the code for the detail section's Format event procedure would be:

Dim sec As Section
Dim ctrl As Control

Set sec = Me.Section(acDetail)

If Me.[Date Entered] = DateAdd("d",-60,VBA.Date) Then
sec.BackColor = vbRed
For Each ctrl In sec.Controls
ctrl.BackColor = vbRed
Next ctrl
Else
sec.BackColor = vbWhite
For Each ctrl In sec.Controls
ctrl.BackColor = vbWhite
Next ctrl
End If

Ken Sheridan
Stafford, England

"Adam Milligan" wrote:

In the "on format" event of the detail section enter something along the
lines of the following code:

If Me.[DateEntered] Date()-60 then

me.detail.backcolor = 255

end if


"Very Basic User" wrote:

Hello,

I'm trying to have a cell in a report turn red if the item is still active
in a data base. In other words. I have an action register. for my report, I
filter out everything that is not "in progress" I have a "Date entered"
field. What I would like is if the item is still "in progress" 60 days after
teh "date entered" I would like the report line to turn red.

Any help would be appreciated!
--
Thank you for your time!
John

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:37 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.