change color of details row

freeflight123
freeflight123 used Ask the Experts™
on
Hi,

how can I change the color of a details row, e.g. if
table.created=NOW() then the whole row should turn into red
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
Open the report
Click FORMAT --> FORMAT SECTION
Select the detail section
In CR 7 there is a color tab.  Other version may be slightly different
Click the COLOR tab
Select the formula button next to background color
Enter

If ({table.created} = CurrentTime()) then
  red


CurrentTime may be the wrong function.  Select the function from the function menu.

mlmcc
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
In CR7 the date is CurrentDate()

mlmcc
I concur with mlmcc, but because of a Crystal "quirk" be sure to add an "else" to this particular formula (or the entire background will black out, so:

v8 or higher
If ({table.created} = CurrentTime()) then
 red else defaultattribute

v7
If ({table.created} = Currentdate()) then
 red else white

(or I think v7 included "nocolor" also)
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Commented:
Hi.

Depends what you mean in "turning red":
- if changing background for detail section see mlmcc's comment above
- if changing background for part of the section see my comment at http://www.experts-exchange.com/Databases/Crystal_Reports/Q_20723536.html
- if changing font (but not background): create a formula that returns color and use the formula in Format/Font?Color for each field in the detail section.

By the way, Now and CurrentTime are identical, but Now is provided for backward compatibility. Better use CurrentTime.
Also, I doubt that timestamp when you're running a report could be equal to any timestamp in the database. But it depends of the task too...

Good Luck.
PW
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Thanks Pat.  Didn't know that since I haven't used that feature much.  I believe I used in a couple of reports so I'll verify you are correct.

mlmcc

Author

Commented:
thanks guys, works!
how can I have it in e.g. #FFCCCC instead of red?

Commented:
Hi.

Sure, you can. Use Color(r,g,b), where r,g,b are bytes. As well you can create a function that converts hex values to bytes. :-)

Good Luck.
PW
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Glad I could help

mlmcc

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial