Phuong Tr
Phuong Tr

Reputation: 37

Multiple if else in Crystal Report

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?

Upvotes: 2

Views: 21589

Answers (1)

aMazing
aMazing

Reputation: 1460

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.

Upvotes: 6

Related Questions