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

if statement issues

Status
Not open for further replies.

Stewman

MIS
Jan 23, 2002
79
US
Hello,

Not a programmer at all. Trying to do a formula in crystal.

getting boolean required here and highlights the else statement.

Trying the following:

If {INV_CODE} = 'PER' then
{CHG} = " "
Else {CHG}

What I'm trying to say is if involvement code is equal to PER then I want to the chg field to be blank, else display the value in chg field. What do I do to fix this?

All help appreciated.

Thanks in advance!
 
Try this:

If {INV_CODE} = 'PER' then " "
Else {CHG}

You can't set a field or a formula to a value within a formula, you can just use the field or formula values. Your formula just needs to return the value you want to see on the report.

-Dell


A computer only does what you actually told it to do - not what you thought you told it to do.
 
Thanks that worked. Now running into another problem.

if {INV_CODE} = 'PER' then
{INV_DESCR} = 'ACCIDENT'
ELSE {INV_DESCR}

I want to display the inv description on another field but it is giving me the same boolean error. Any ideas?
 
Hi,
same issue as was pointed out..you only need to display the outcome you need:


if {INV_CODE} = 'PER' then
'ACCIDENT'
ELSE {INV_DESCR}

You CANNOT assign a value to a database field in the report.



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
This doesn't give me the result I want. I want the description field to say 'accident' if the inv_type is 'PER'. If INV_TYPE is anything else, then I want it to say whatever the descr field has in it.
 
Hi,
Just clear up something please,
you indiace that
IF {INV_CODE} = 'PER' you
want 'Accident' or the value in {INV_DESCR}
BUT
you also indicate that
IF {INV_CODE} = 'PER' you
want "" or the value in {CHG}

Seems to be a conflict here...the same test cannot produce 2 sets of results -- how would the report parser know which result you wanted - "", {CHG},'Accident' or {INV_DESCR}?

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Let me explain the setup. I have a report that lists the following three fields.

inv type chg inv_descr

What I want is if inv_type = 'PER' then the chg field needs to be blank and the inv_descr field needs to say accident.

For all other INV_TYPE just display whatever the values are for chg and descr.

Hope this helps.
 
Hi,
OK try:
2 formulas, one for chg and one for inv_descr
Code:
@chg_field
If IF {INV_CODE} = 'PER' 
then ""
Else
{CHG}
Code:
@inv_type_field
If IF {INV_CODE} = 'PER' 
then 
'Accident'
Else
{INV_DESCR}







[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks for your help. This is what I have already. The chg is blank which is correct but the descr is not saying accident, it is just blank.
 
Hi,
Of course, ignore the double IFs , just one is needed for each formula..[ copy and paste can be too efficient sometimes [blush]]

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Hi,ODD,

Try just the 'Accident' or {INV_DESC} formula to see if maybe the {INV_DESC} field has any blanks when {INV_CODE} = 'PER'

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I did ignore the double ifs. In some instances there will be blank descr but it is very rare.
Heading out, won't be able to to check back till tonight. Thanks for all your help Turkbear
 
Hi,
Just in case, modify the formulas to handle NULLS:

Code:
@chg_field
If ( Not IsNull({CHG}) or Trim({CHG}) <> "" ) 
Then
 IF {INV_CODE} = 'PER' 
  then ""
  Else
  {CHG}
Else
""


Code:
If ( Not IsNull({INV_DESCR}) or Trim({INV_DESCR}) <> "" ) 
Then
 IF {INV_CODE} = 'PER' 
  then 
 'Accident'
 Else
  {INV_DESCR}
Else
 'Accident'

If INV_CODE can also be blank or NULL then add a similar test before checking its value.





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top