Reputation: 123
I created a crystal report and I added a Formula Field (stock).
This is the formula I added to this field (Basic Syntax):
if not IsNull ({LigneBonLivraison.Quantite}) Then
{@stock} = {Article.StockActuel} - {LigneBonLivraison.Quantite}
else
{@stock} = {Article.StockActuel}
But I get this error "A Statement is expected here" in this line:
{@stock} = {Article.StockActuel} - {LigneBonLivraison.Quantite}
So how to fix it??
Upvotes: 0
Views: 34461
Reputation: 3370
for binding use :=
instead of =
if not IsNull ({LigneBonLivraison.Quantite}) Then
{@stock} := {Article.StockActuel} - {LigneBonLivraison.Quantite}
else
{@stock} := {Article.StockActuel}
for more information refer this link If Expressions (Crystal Syntax)
for basic syntax use End If
at end of if:
if not IsNull ({LigneBonLivraison.Quantite}) Then
{@stock} = {Article.StockActuel} - {LigneBonLivraison.Quantite}
else
{@stock} = {Article.StockActuel}
End If
the If-Then-Else statements in Basic syntax differ from those Crystal syntax versions described previously. Basic syntax follows the more typical If-Then-Else-EndIf approach familiar to Basic language programmers. In particular, this makes performing multiple actions as the result of a single If-Then-Else statement more straightforward by introducing the End If clause:
If <test> Then
<statement>
<statement>
<more statements>
Else
<statement>
<statement>
<more statements>
End If
Also, you can use the Basic syntax ElseIf clause (don't forget it's one word ”no space) to allow nesting of multiple If conditions in one statement:
If <first test> Then
<statements>
ElseIf <second test> Then
<second test statements>
Else
<statements if first test fails>
End If
Upvotes: 1