Solved

Posted on 2005-04-27

Hey all....another question

I am using selection formatting to evaluate a field value and then apply color based upon the field value. My formual is listed below....

Select CurrentFieldValue

case is >= 1 :crRed

case is > .75 :Color (244,134,11)

case 0 :crNoColor

case is <= .50 :crLime

case is <= .75 :crYellow

default

I have a new value 'NB' which is text....How can I incorporate this into my code above...

I have tried

Select CurrentFieldValue

case = 'NB' :crRed

case is >= 1 :crRed

case is > .75 :Color (244,134,11)

case 0 :crNoColor

case is <= .50 :crLime

case is <= .75 :crYellow

default

That didnt work...I am pretty sure its because its text and not a number....Any push in the right direction would be helpful.

Thanks,

bob

I am using selection formatting to evaluate a field value and then apply color based upon the field value. My formual is listed below....

Select CurrentFieldValue

case is >= 1 :crRed

case is > .75 :Color (244,134,11)

case 0 :crNoColor

case is <= .50 :crLime

case is <= .75 :crYellow

default

I have a new value 'NB' which is text....How can I incorporate this into my code above...

I have tried

Select CurrentFieldValue

case = 'NB' :crRed

case is >= 1 :crRed

case is > .75 :Color (244,134,11)

case 0 :crNoColor

case is <= .50 :crLime

case is <= .75 :crYellow

default

That didnt work...I am pretty sure its because its text and not a number....Any push in the right direction would be helpful.

Thanks,

bob

13 Comments

Try changing it to this:

if CurrentFieldValue = "NB" then

crRed

else

Select val(CurrentFieldValue)

case is >= 1 :crRed

case is > .75 :Color (244,134,11)

case 0 :crNoColor

case is <= .75 :crYellow

case is <= .50 :crLime

default :crNoColor

"A number is required here"..........it referes to the "NB"

Try highlighting the field in the Fields list, right click it and choose Browse Data.

This will give you the data type and the first 500 unique values in the field.

Post the data type and what you found out about the data.

If {Budget Amount Computer Services}= 0 and {Computer Services Expenses} = 0 then

'0'

else

(

IF {Budget Amount Computer Services}= 0 then

'NB'

else

cstr(({Computer Services Expenses}/{Budget Amount Computer Services}) * 100)

)

The formula will return a numeric value or a text value.......

Does that make sense

case = 'NB' :crRed

case is >= 1 :crRed

First case is string, second is number. Change second one to string to:

case = 'NB' :crRed

case is >= CInt('1') :crRed

Lady Linet

I am not sure why the last code I gave you is not working. Perhaps we should simplify it for the time being to try and get it working.

Try this for now:

if CurrentFieldValue = "NB" then

crRed

else

crNoColor

Let me know if that works

if CurrentFieldValue = "NB" then

crRed

else

crNoColor

And it still complains about "A number is required here" .....referring to the NB.

The field that I am applying this formual to can either be a number or string field........

In the example above...I dont understand why Crystal cares if the field value is a number or string.....just evaluate based upon my formula......

bob

I tried your code and have the same problem........It doesnt like that "NB" is a string........instead of a number.

Keep getting the "A number is required here"

bob

The data may look like it is either numeric or text but the formula can only return one data type. Because you put quotes around the 0 and used the cstr function, you have converted the numeric data to text.

Are you sure you have this in the font color for the formula and not in the font color for another field?

If you use the formula name instead of CurrentFieldValue do you get the same error:

if {@formula_name} = "NB" then

crRed

else

Select val({@formula_name})

case is >= 1 :crRed

case is > .75 :Color (244,134,11)

case 0 :crNoColor

case is <= .75 :crYellow

case is <= .50 :crLime

default :crNoColor

It can't be both, so you should choose one, string will be better because you can use both 'NB' and '0'.

Covert all cases into strings:

case = 'NB' :crRed

case is >= '1' :crRed

case is > '0.75' :Color (244,134,11)

case '0' :crNoColor

case is <= '.75' :crYellow

case is <= '.50' :crLime

default :crNoColor

Lady Linet

I had selected all the formulas at once and inserted the code CurrentFieldValue.........

When I went thru and specified the specific formula and removed the currentfieldvalue it works like a charm. The downside...I have to setup about 40 of these that specify the formula instead of setting it up once for all of them.

But, considering I have already spent way too much time on this....Its time well spent.

Thanks everyone for helping me. I really appreciate it!!!! Some days are harder than others......

Today was a hard one :)

Thanks.

Bob

Title | # Comments | Views | Activity |
---|---|---|---|

DateAdd function | 2 | 40 | |

Crystal Reports 11 Ignoring Parameters | 3 | 44 | |

Crystal Reports. Need to find the earliest activity record by timestamp for each ticket. | 16 | 49 | |

Crystal Reports last day of month | 2 | 20 |

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**19** Experts available now in Live!