Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: If/Then in SQL Post Reply Post New Topic
Author Message
thesmug1
Newbie
Newbie
Avatar

Joined: 12 Jun 2009
Online Status: Offline
Posts: 13
Quote thesmug1 Replybullet Topic: If/Then in SQL
     Posted: 27 Apr 2011 at 10:13am
I have a small problem with a report I am making. I wrote the following code for a Formula Field:

if {TLORDER.BILL_TO_CODE} like "D%" then

    {TLORDER.DESTNAME}

else if {TLORDER.BILL_TO_CODE} like "P%" then

    {TLORDER.ORIGNAME}

   

My goal is if the Bill To starts with a D, then it will display the DESTNAME field; if it starts with P, then it will display the ORIGNAME field. However, the field always comes up empty.

Any help in getting the field to display would be most appreciated.

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Apr 2011 at 10:58am
looks like you are doing a hybrid crystal/sql code. SQL uses % , crystal uses *
if {TLORDER.BILL_TO_CODE} like "D*" then {TLORDER.DESTNAME}

else if {TLORDER.BILL_TO_CODE} like "P*" then {TLORDER.ORIGNAME}

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Apr 2011 at 12:07pm
note that you can also use the startswith option in crystal syntax
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum