Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: If Else Formula Post Reply Post New Topic
Author Message
scsfdev
Newbie
Newbie
Avatar

Joined: 27 Jun 2009
Online Status: Offline
Posts: 2
Quote scsfdev Replybullet Topic: If Else Formula
     Posted: 20 May 2010 at 6:26pm
Hi all,

I have a crystal report from vb.net 2005.

I want to edit one of the "Record Selection" formula I have in my report. (Selection Formulas >> Record Selection)

In my report it has only one If ... Else ...
However, I want to add more than one If Else.

this is the original formula

if {?sLocation} <> "" then
    {tblCategory.loc_id} = {?sLocation}
else
    {tblCategory.wh_id} = {?sWareHouse}


And here is my changes

if {?sLocation} <> "" then
    {tblCategory.loc_id} = {?sLocation}
if {?sWareHouse} <> "" then
    {tblCategory.wh_id} = {?sWareHouse}
if {?sUserid} <> "" then
    {tblCategory.user_id} = {?sUserid}

When I click on "Check" to check my formula, it gave me following error msg.
The remaining text does not appear to be part of the formula.

Did my formula is not correct???
Anybody can guide me on this??

Thanks.
IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet Posted: 24 May 2010 at 1:29am
Yup. You missed 'else' statement there.
It should be:
If ..... then
          ......
else if ..... then
               .....
else if ...... then
               .....
 
 
 
Or you can try this:
 
({?sloc}="" or {tbl.fieldloc}={?sloc})
and
({?whouse}="" or {tbl.fieldwh}={?whouse})
and
({?usrid}="" or {tbl.fieldusr}={?usrid})
 
 
 
hope it help.
 
Emir W
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 25 May 2010 at 2:54am
or you could just add ; after the first {?sWareHouse}
depending on if this is the logic that you were thinking.
IP IP Logged
scsfdev
Newbie
Newbie
Avatar

Joined: 27 Jun 2009
Online Status: Offline
Posts: 2
Quote scsfdev Replybullet Posted: 21 Jun 2010 at 4:12pm
Hi Emir_W, lockwelle ,

Thanks for ur support.
Sorry, I'm on a long vacation :)
I tried your way (Emir_W) and its working so i didn't try lockwelle way :) sorry!

What I did was i used below method and its working! :)
({?sloc}="" or {tbl.fieldloc}={?sloc})
and
({?whouse}="" or {tbl.fieldwh}={?whouse})
and
({?usrid}="" or {tbl.fieldusr}={?usrid})

Thanks u all, this issue has been troubled me for a long time because I'm not that expert in crystal formula. but now its solved!!

Thanks again.
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