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

Issues If-then-else; Condition #1 number, #2 text 4

Status
Not open for further replies.

SouthwestNut

Programmer
Sep 10, 2001
35
US
I am attempting to write a conditional statement that if A<>0 then A else "N/A". However CR9 requires that both branches of the If statement be the same data type (as best as I can figure).

Any easy way arount this?

Thanks
 
Hi,
Convert them into the same type:

"A" <> totext(0) then "A" else "N/A".



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
if A<>0 then
cstr(A)
else
"N/A"

Then they both come out as strings.
 
Thanks so much to both responders. So if I follow your suggestions then I will put the same field in the body of my report two times, one time in the detail and a second (suppressed) value in my detail that I will use to summarize my data in the report footer.

Thanks again.
 
There is a simpler approach that doesn't require any formuals. Just put the field on the report and then go into Format-Field and click "Customize". There is a property that allows you to set how zeros should show. Type N/A there and all zeros will show as N/A without affecting your totals.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides for Formulas, Parameters, Subreports, VB, .NET, Tips and Tricks
 
This works great ... however when I format to percent, the field with the N/A shows as "N/A%". Is there anyway to remove the formatting for cases when it does not apply?

Thanks in advance and hopefully these answers will help many developers.
 
You can also control when the % sign appears by using the X-2 formula that controls the currency symbol

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides for Formulas, Parameters, Subreports, VB, .NET, Tips and Tricks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top