Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternate coloring of records based on 4 day intervals 2

Status
Not open for further replies.

PDAnalyst

Technical User
Dec 2, 2005
72
US
Hello,

I am using CR 2013 on an SQL database.

I have a request to color records that are in 4 day bins starting from December 31, 2016 in alternate colors (2 colors)
so at the end my report should look like:

Dec 31, 2016 to Jan 3, 2017 - Color blue
Jan 4, 2017 to Jan 7, 2017 - Color green
Jan 8, 2017 to Jan 11, 2017 - Color blue
Jan 12, 2017 to Jan 15, 2017 - Color green
Jan 16, 2017 to Jan 19, 2017 - Color blue
Jan 20, 2017 to Jan 23, 2017 - Color green
..... etc.

is there a way to accomplish this?

Any help is appreciated.
Thanks
S.E.
 
I am assuming you are talking at the detail level. I would think it would be possible, but definitely would take some thought on how to do it. My first thought is a date diff from Dec 31, 2016, then do a modulo or remainder. But I do not have details yet.
 
Yes,

it will be for coloring the details section based on the 4 day increments.

Thanks
 
I did it this way:

Code:
If      Remainder(Round(DateDiff('d', Date(2016, 12, 29), Date({Table.DATE}))/4,0),2) = 1
Then    crBlue
Else    crGreen

Hope this helps.
 
First limit your records using a date parameter {?StartDate} in your selection formula:

{table.date}>={?StartDate}

Then go into the section expert->details->color tab->background color->x+2 and enter:

whileprintingrecords;
datevar start := {?StartDate};
numbervar cnt;
numbervar rng;
numbervar curr;

if onfirstrecord or
date({table.date})=previous({table.date}) + 1 then
cnt := cnt + 1 else
cnt := cnt;
if cnt = 9 then
cnt := 1;
rng := day(dateadd("d",cnt, start-day(start)));

if rng < 5 then
curr := crblue;
if rng > 4 then
curr := crgreen;
curr

You might want to replace crblue and crgreen with some lighter hues for readability. You can create custom colors using the color function: color(R,G,B).

-LB
 
pmax9999,

Sorry--cross-post. Your solution is simpler than mine.

-LB

 
No stress LB. Obviously both working on the solution at the same time.

My initial thought was to take the approach you did - but pure laziness often drives me to find simpler solutions.

I don't often get the chance to beat you to a solution - I suspect I am at a timezone disadvantage - that's my excuse anyway, and I'm stickin' to it. [bigsmile]

Cheers
Pete.
 
Thank you for both,

as always this site and users are the greatest.

You guys and gals have saved me countless hours spent trying to find a way to overcome this and from pulling the few hairs left on my head out,

Safa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top