# Crystal formula result question

This formula returns 75.00 everytime. The field HourlyRate defaults to 75.00. Then I check the location and employee type to determine if the hourly Rate should be chaned to 65.00 or 25.00.
What's the correct way to do this? I've been trying various things like instr but am not having luck. I need a formula that returns a number. If I remove the last line the formula returns true or false. Thanks.

Global NumberVar HourlyRate;
HourlyRate := 75.00;

If {Projects.Location} like "Apples" then
HourlyRate := 25.00;

If {Projects.Employee Type} like "Oranges" then
HourlyRate = 65.00;

HourlyRate;
###### Who is Participating?

Commented:
I added * * around your text.  Like needs them to do a wildcard search.

mlmcc
0

Commented:
Try this
WhilePrintingRecords;
Global NumberVar HourlyRate;
HourlyRate := 75.00;

If {Projects.Location} like "*Apples*" then
HourlyRate := 25.00;

If {Projects.Employee Type} like "*Oranges*" then
HourlyRate = 65.00;

HourlyRate;

mlmcc
0

Author Commented:
H Mlmcc. The formula you suggested look like the one I tried. I'm not seeing the difference
between yours and the one I posted.
0

Author Commented:
I did add the WhilePrintingRecords but it still comes out to 75.00 everytime.
0

Commented:
mlmcc's right about the "*"s.  You need those for LIKE.  Another problem is this line near the end of your formula:

HourlyRate = 65.00;

That should be:

HourlyRate := 65.00;

:= assigns a value to a variable.  = compares values.  It's an easy mistake to make, and to miss.

So, if "Employee Type" contained Oranges, you were just comparing HourlyRate to 65, instead of setting it to 65.  That's why you got True or False when you removed the last line.  Actually, it should have always returned False.

If you're still not getting the correct results after changing that, then there's something else going on.  Presumably "Apples" and "Oranges" are just example values.  If your real values are more complicated, maybe your tests aren't working.  Case might also be an issue (depending on your settings, "apples" may or may not match "*Apples*").  And if any of those fields could be null, that could be a problem.

James
0

Author Commented:
Thanks! the 2 suggestions given to me worked.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.