Click here to Skip to main content
11,487,406 members (72,257 online)
Rate this: bad
Please Sign up or sign in to vote.
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"
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 7-Jan-13 18:39pm
Des DC533
Aarti Meswania at 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"
Sergey Alexandrovich Kryukov at 8-Jan-13 0:23am
Those are not statements, but expressions. Do you know the difference? :-) There are no statements, which is wrong.
Des DC at 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 at 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 at 9-Jan-13 8:52am
replace the last else with - OrElse
Des DC at 9-Jan-13 19:59pm
sorry for late.
I solved my problem.
My solution is convert it into char first before retrieve into crystal report. :)

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,063
1 OriginalGriff 8,287
2 Sascha Lefèvre 3,334
3 Maciej Los 2,946
4 Richard Deeming 2,370

Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100