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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use color to indicate a field value?

Status
Not open for further replies.

MMock

Programmer
Aug 23, 2007
17
US
I'm converting a Windows VB project from Access to VS .net 2005. The report currently in Access does something really cool with color-coding that I just want to know if it's possible to also do with Crystal Reports.

There are boolean values in the database to indicate whether a component needs to be built. If it's checked off on the screen the user can enter the date it was completed and that gets written to the database. On the report is a checkbox which is checked if the component is being built. If the checkbox has a larger grey square around it, that indicates the component was completed. If the entire line on the report, corresponding to one record, is all grey, that means all the components in the order are complete.

The report is cluttered already so I guess the color-coding gives a nice visual presentation of data without having to add more written information.

I don't know how to insert a screen shot or attach the image or I could show you what I mean. I hope I explained it clearly.

Can do?

Thanks.
 
Okay, I think I'm onto something. I found this at this link:
if (Sales.Profit) < 0 then crRed else crBlack

So now I'm pretty sure I can do what I want to do. But I still have a question, because I'm new at writing formulas, and new at everything Crystal. The formula above turns Sales.Profit red or black. I want to test a date but the date isn't on my report, its component is. The date is returned by the stored procedure which is the datasource of my report. Can someone help me with this formual? It's something like,

if rptRawDate <> "" then
Raw = crRed
else
Raw = crBlack

However, I already have a formula for Raw because I need to represent it as an unchecked checkbox or a checked checkbox like so:
If {spCr_NewCoverage;1.Raw} = True Then
Chr(254)
Else
Chr(168)

I would have to add the highlighting formula into this formula.

Sorry to be such a pain. Thanks!
 
Okay, the Formatting Formulas are separate from the Formula Fields so I didn't have to combine them, I did it in two steps. This is the Formula Field for RawCheckbox:

If {spCr_NewCoverage;1.Raw} = True Then
Chr(254)
Else
Chr(168)

And this is my Formatting Forumula also for RawCheckbox, Background Color, but defined under Details:

if {spCr_NewCoverage;1.rptRawDate} = "" then
crNoColor
else
crGray

I still have to figure out how to get the whole line grey when another column from my sp, CompletionDate is not blank. That means all the components are complete.

Thank you. I hope what I'm finding will help someone in the future and I'll be back when I answer the final part of my question (unless someone else gets to it first!)
 
You probably need totest for nulls using the isnull() function, rather than testing for "".

Also, you are in the wrong forum. This forum is about Crystal Data Access - as in how to connect to data sources. You should post this in the Crystal Reports Formulas forum.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If the phone doesn't ring, it's me".....Jimmy Buffet
 
Thank you for CMA (that's a variation of CYA, but you do it for somebody else)!

Also, I just found this forum and my first question was about data access so I just continued on in the section I first found! Sorry...I'll get out!
 
To color a section, go into the section expert, select the section you want colored->color tab->background->x+2 and enter your formula there:

if isnull({table.date}) or
{table.date} = date(0,0,0) then
crYellow else crNocolor

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top