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

Simple If Then Statement

Status
Not open for further replies.

WPCMS

Technical User
Jun 28, 2007
29
US
I use CR IX and I am a new user. I have a simple formula (at least I think it is) to add to my report.

//crystal syntax
WhilePrintingRecords;
If {Asgnmnt.CSHold} = "True"
then "HOLD"
Else ""


When I view the report it is "" all the way. {Asgnmnt.CSHold} is a check box, so I am assuming this is a Boolean T/F.

WPCMS
 
Try displaying {Asgnmnt.CSHold}. IT should show True or False, which is what happens with boolian formula fields.

Also try using ISNULL in your test: unfilled fields can often be nulls and hitting a null will always stop a formula.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
//Crystal Syntax
WhilePrintingRecords;

If (not isnull({Asgnmnt.CSHold}) = "True"
then "HOLD"
Else ""

There is an error, I am pretty sure I am missing something.
 
It probably should be expressed without the quotes. You also don't need "whileprintingrecords".

If {Asgnmnt.CSHold} = true
then "HOLD"
Else ""

-LB
 
Try this:

If isnull({Asgnmnt.CSHold}) then "HOLD" else
if {Asgnmnt.CSHold} then "HOLD" else ""

WhilePrintingRecords should not be needed.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
Put the field {Asgnmnt.CSHold} in the detail section and then report back with what it displays--or right click on it and choose browse data and then let us know.

-LB
 
Put the tests into several separate formula fields. Put them onto a test detail line under the main detail line. Find what result it's actually getting.

You've been given formulas that should work, so it's highly likely the data is not what you think it is.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Browsing the data it says T,F or blank. I entered the formula exactly

If isnull({Asgnmnt.CSHold})
then "HOLD"
else if {Asgnmnt.CSHold}
then "HOLD"
else ""

and I get a formula error saying "HOLD" a statment is expected here.When I switch it to Crystal Syntax it says {Asgnmnt.CSHOLD} Boolean statement expected here.this is Driving me nuts.
Maybe this is not so simple after all! What am I not seeing?
 
Hi,
Blanks are not the same, always, as NULLs so test for both:
Code:
If (
 isnull({Asgnmnt.CSHold})
 OR 
 Trim(({Asgnmnt.CSHold}) =""
 OR
 {Asgnmnt.CSHold} = "F" 
)
then 
"" 
Else
"HOLD"


[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Your "else if" doesn't have a condition.

You've stated:
"if {Asgnmnt.CSHold} ISNULL then"

but when you say "else if" you don't tell it "if what". In other words, is it if CSHold is True? if CSHold is False, etc.

Try giving your "else if" a condition.
If isnull({Asgnmnt.CSHold})
then "HOLD"
else if {Asgnmnt.CSHold} = "True"
then "HOLD"
else ""

 
Navy,

The field is not a true/false (also known as boolean) field. It is a char field with values of "T", "F" or null.

Use Turkbear's formula.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
None of the above worked so I fiddled with it and researched and it worked with this formula.

If {Asgnmnt.CSHold}=""
then ""
else if {Asgnmnt.CSHold} = "T"
then "HOLD"
else ""

WPCMS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top