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

Crystal 9.0 If Then Else problem

Status
Not open for further replies.

DeirdreMarie

Technical User
Mar 14, 2005
2
US
Good afternoon.

I am new to using Crystal Reports and am having trouble writing a simple formula.

I have a field which can contain several options. I do not want to filter the field, but simply display a Yes or No if a condition applies.

I have written, If {EquipmentMaster.ShortDesc}="MCS" Then
"Yes"
Else "No"

When the formula field is entered into the report, it removes all data. The {EquipmentMaster.ShortDesc}is a text field.

Your assistance is appreciated.
 
What does removes all data mean, that the report doesn't return any rows, or it doesn't display yes or no, or?

Try:

If isnull({EquipmentMaster.ShortDesc})
or
{EquipmentMaster.ShortDesc}<>"MCS" Then
"No"
Else
"Yes"

If you're using a field from a table wherein a join exists that will result in no rows being returned, and this is the only field pulled from that table, then I can understand no data in the report as Crystal will not use the additional table unless there's a field being used in the report, so the issue might be related to this, but clarifying what removes all data means will help us to assist you.

-k
 
Thank you for the reply.

I used the formula you provided and once again no rows were returned.

I placed the {EquipmentMaster.ShortDesc} field on the report (page footer) and suppressed it from being displayed.

This seems like it should be very easy yet it's causing me much grief.
 
Deidre:

Is the formula you are using intended to affect the display of data above this report footer field? Is the result of this test e.g. "Yes" or "No" used in another forumla?

It's also helpful to all responders if you include the version of Crystal Reports and the data source (DB2, MS-SQL, etc.) that you are running your reports against.
 
I wonder whether you are creating this formula in the correct area. You should be creating it in the formula expert, not the record selection formula area. It would probably help if you explained more specifically how you wanted to use the formula, e.g., for display in the detail area, etc.

-LB
 
Just to help you understand better, if a field is referenced which has an equal join to a table which would result in nor rows being returned, than it has nothing to do with Crystal, it is the joins in the database.

As LB pointed out, perhaps you are using this formula in the wrong place, as you shouldn't be placing the field {EquipmentMaster.ShortDesc} in the report at all, you should be using this formula as your display.

Formulas are created by right clicking the Formula Fields within the Field Explorere and selecting New.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top