Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi all,
I facing a problem while using if else statement.
here my code
stringvar halfshare := ToText({DataNormal.IsHalfShare});
stringvar margin := ToText({DataNormal.Margin});

if halfshare = "0" then
margin & "      " & "S"
else if halfshare = "1" then
margin & "      " & "H"
else 
margin & "      " & "R";


I have declaring the variable as above in the formula bar of crystal report. But my output is only display the last statement which is
margin & "      " & "R"
.
Can anyone tell me where is my problem/error?
Posted
Comments
Aarti Meswania 7-Jan-13 23:58pm    
comment if-else portion and just print
halfshare variable
it will always having value Except 0 and 1 that's why it always goes in last else part and printing
margin & " " & "R"
value
Sergey Alexandrovich Kryukov 8-Jan-13 0:23am    
Those are not statements, but expressions. Do you know the difference? :-) There are no statements, which is wrong.
—SA
Des DC 8-Jan-13 1:01am    
Aarti Meswania,my database information is saved as 0,1 or 2 in {DataNormal.IsHalfShare}. so i want the system to differentiate it.
Des DC 8-Jan-13 1:01am    
Sergey Alexandrovich Kryukov,really?because my database is saved as 0,1,2 in {DataNormal.IsHalfShare}.so i wish to display it in S,H or R.
thomasriley 9-Jan-13 8:52am    
replace the last else with - OrElse

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900