Skip to Content
0
Aug 24, 2012 at 10:49 AM

CR - How to code for "Negation"?

9 Views

Hi everybody,

I am using Crystal Reports 2008.

In Field Explorer, I have a formula field called "Error" which contains the following code:

If (InStr(Join({?BankAcctNumber}), "Euro") > 0 AND "EUR" in {Command.Currency}) THEN "This is an Error!"

A brief explanation:

The JOIN command joins several user-selected choices together. E.g if User selects "Euro" and "Dollar", JOIN returns the string "EURO, DOLLAR"

"BankAcctNumber" is a parameter field in CR

The INSTR command checks whether a given substring (here "Euro") is found within a given String (here INSTR etc... )

= 0 means that the Substring is not found

> 0 means that the Substring is found somewhere in the main string.

What my code means is the following:

If the user selects "Euro" AND the currency (in detail section) is "EUR" , then the Error message is displayed.

I want to modify my code so that it reads:

If the user selects "Euro" AND the currency (in detail section) is NOT "EUR" , then the Error message is displayed.

How can I do this?

Thanks

Leon Lai

PS:

I tried the foll, and although there is no error, it does not work as expected:

IF (InStr(Join({?BankAcctNumber}), "Euro") > 0)
AND
not( "EUR" in {Command.Ccy})


then "This is an Error!"