Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi... Is there any possibility that i can use if else in crystal report..

My requirement is there are 3 fields are there in a table i.e., 'Phone','mobile1' and 'mobile2' and i wrote a formula field as

{CustDetail.Phone}+' '+trim('/')+' '+{CustDetail.Mobile1}+trim('/')+''+{CustDetail.Mobile2}

but suppose mobile2 is not exist means that '/' should not display....

please check following snapshot

http://s18.postimage.org/6gifkt7mh/image.jpg
Posted

yes you can write if and else inside the formula fields, it something like this

VB
if {table1.id} <> 1 then
   var1 := "Hello";
else
   var1 := "Bye";


I hope this will help you to solve your problem
 
Share this answer
 
if {CustDetail.Phone} >0 and {CustDetail.Mobile1}>0 and {CustDetail.Mobile2}>0 then
{CustDetail.Phone} + " / " + {CustDetail.Mobile1} + " / " +{CustDetail.Mobile2}
else if {CustDetail.Phone} >0 and {CustDetail.Mobile1}>0 and {CustDetail.Mobile2}=0 then
{CustDetail.Phone} + " / " + {CustDetail.Mobile1}
else if {CustDetail.Phone} >0 and {CustDetail.Mobile1}=0 and {CustDetail.Mobile2}=0
{CustDetail.Phone}




I hope it will help you better. If yes please say me thanks.
 
Share this answer
 

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