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

Formatting formula 1

Status
Not open for further replies.

JMG1019

Technical User
Aug 31, 2006
5
US
Hi,

I use Crystal Reports 11. We pull data from individuals records and compare those values to a set group of compliant values. If the individual is not compliant we need the name to be highlighted (in our case crred and crbolditalic). The problem I am running into is that there are several criteria that must be met by each individual. Some cases require an isnull, others a date subtraction and others a straight comparison to a value. I found that if I rearranged all of the criteria in differing orders (i.e. isnull first then date subtraction and finally value comparison) I would yield the desired results.

This explanation leads me to my question. Is there an order of operations, so to speak, when utilizing criteria in a formula? When I used the formula in a different order the individual record was not highlighted. The following code works when the isnull values are listed first. If the isnull values are mixed it doesn't work. I would appreciate any suggestions.

Thanks!

if (
isnull({Command.ADATE})=true or
isnull({Command.LDATE})=true or
(isnull({Command.LASTA})=true) or
isnull({Command.LASTBSYS})=true or
(isnull({Command.TOB}) = false and isnull({Command.SMOKE}) = false) or
(isnull({Command.ANTIPL}) and {Command.AGE} > 40) or
({Command.ADATE} < DateAdd ("m", -6 , currentdate)) or
({Command.LASTA} >= 7.0) or
({Command.LDATE} < DateAdd ("m", -12 , currentdate)) or
({Command.LASTL} >= 100) or
({Command.LASTBPSYS} >= 130) or
({Command.LASTBDIA} >= 80)
) then crred
 
You need to do a null test before trying to use a field. Crystal formulas stop without output if they hit a null, even if the null is tested for later on.

You can also write tests as Boolians, e.g.
Code:
isnull({Command.ADATE})=true or
isnull({Command.LDATE})=true or
(isnull({Command.LASTA})=true) or 
isnull({Command.LASTBSYS})=true
If this was called @SomeNull, your formula could just say not @SomeNull. You could also display it on a detail line while developing your report, seeing it say True or False and confirming that the test is working.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top