cancel
Showing results for 
Search instead for 
Did you mean: 

CR - How to code for "Negation"?

leon_laikan
Participant
0 Kudos

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!"

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Leon Lai,

try it on multiple levels:

iif(

     InStr(Join({?BankAcctNumber}), "Euro") > 0,

          iif("EUR" not in {Command.Ccy},

               "This is an error",

               "OK")

     ,"OK")

also what do you mean by not working as expected?

Regards,

D

leon_laikan
Participant
0 Kudos

Dear Daniel,

Thanks for your answer.

I had already figured out the answer and closed my thread.

Best Regards

Leon

Answers (0)