Multiple if else in Crystal Report

14,709

I have only added a semi colon on the first line of you code and it works as you have it. But Apart from that considering you are new to CR, have alook at the formatting I have done. Its entirely upto your personal preference, but I would keep keyword Then on the same line as If and logic on the next line.

Stringvar result :=""; // Only Added Semicolon here.
If ToText(Trim(name)) = 'A' Then 
     result := '98'
Else If ToText(Trim(name)) = 'B' Then 
         result :='99'
     Else 
         result := name;
result

As for Part 2 of your question, there is no such one "Document" that you can use to learn CR. Here are a few links:

1) Link 1

2) Link 2

3) Link 3

The list is exhaustive. You can find a lot of material if you Google.

Share:
14,709
Phuong Tr
Author by

Phuong Tr

Updated on June 15, 2022

Comments

  • Phuong Tr
    Phuong Tr almost 2 years

    I had a case with multiple if else in formula of Crystal Report

    `Stringvar name := Right({vRptAuctionTotalsByBlock.BlockName},2)
    Stringvar result :=""
    If ToText(Trim(name)) = 'A'
    Then result := '98'
    Else
        If ToText(Trim(name)) = 'B'
        Then result :='99'
        Else result := name;
    result`
    

    When I saved it, it showed me the message

    `the remaining text does not appear to be part of the formula`
    

    How can I fix it? Thanks.

    P/s: Where can I find a document to learn how to use Crystal Report?

  • aMazing
    aMazing over 8 years
    Thats great. If my answer was of any help to you please feel free to mark it as answer. Thanks