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!

Can i use If and statements in CR

Status
Not open for further replies.

ghostofelmo

IS-IT--Management
Jul 20, 2006
18
US
I am using the following formula to evaluate the total number of rooms in a job, using Crystal 8. The formula editor sees nothing wrong with the formula, but yet it returns no results. Any thoughts?

IF {P Folder 1.Room 1 Active} = True and {P Folder 2.Room 2 Active} = False then "1" else
IF {P Folder 2.Room 2 Active} = True and {P Folder 3.Room 3 Active} = False then "2" else
IF {P Folder 3.Room 3 Active} = True and {P Folder 4.Room 4 Active} = False then "3" else
IF {P Folder 4.Room 4 Active} = True and {P Folder 5.Room 5 Active} = False then "4" else
"5"
 
Yes, nulls. When writing formulas, any test for null values must come first. Without isnull, Crystal will stop processing the formula when it hits a null value; the default assumption being that null means show nothing. I made this mistake several times while I was learning Crystal, because it's not obvious to someone who's used to other programming languages.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Where would isnull go, because the only results returned by each field is going to be either True or False, False by default. I am trying to determine how many of the rooms are active, by checking against the table for each room.

Thanks
 
Try displaying the values. I think you'll find some are blank

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Format would be
Code:
not isnull(IF {P Folder 1.Room 1 Active}) and {P Folder 1.Room 1 Active} = True

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
You are correct that I am returning some null values good call, now what you sent me is asking for a then because of the IF, I removed it and found no error. Now how do I compare Folder 1 to Folder 2 as true/false. I am trying the following to no avail.

IF (not isnull({P Folder 1.Room 1 Active}) and {P Folder 1.Room 1 Active} = True) and
(not isnull({P Folder 2.Room 2 Active}) and {P Folder 2.Room 2 Active} = False) then "1" else ""

 
How about setting File | Report Options | Convert Null Value Field to Default then using your formula?

Learn something new every day
Using Crystal 8, Oracle Database Paint Shop Pro X1 Nikon D80
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top