Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: If Statement issue Post Reply Post New Topic
Author Message
Karjoe
Newbie
Newbie
Avatar

Joined: 20 Oct 2011
Location: United States
Online Status: Offline
Posts: 5
Quote Karjoe Replybullet Topic: If Statement issue
     Posted: 20 Oct 2011 at 8:12am
Hi,
I have used Access for a long time and I am learning crystal now.  I am tryingto use an if statement to change a record in text box from Y to OK else null.
 
 
IF {Tbl_Objects_Fields.Primary?} like  "Y"
then {Tbl_Objects_Fields.Primary?} ="OK"
else {Tbl_Objects_Fields.Primary?} = " "
 
the above does not work. 
Can someone tell me what I am doing wrong?
 
Thanks in advance
Ismail
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Oct 2011 at 8:21am
Do not try to alter the actual data. Crystal does not insert updates into a row like a sql (or access) update script. just have the "then-else" return the value you want (if you leave of the else it will use the default value for that data type like an empty string)
IF {Tbl_Objects_Fields.Primary?} like "Y" then "OK"
IP IP Logged
Karjoe
Newbie
Newbie
Avatar

Joined: 20 Oct 2011
Location: United States
Online Status: Offline
Posts: 5
Quote Karjoe Replybullet Posted: 20 Oct 2011 at 8:52am
Thanks for the quick response.
 
I am getting this message
 
A string is required here
 
 
Ismail
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Oct 2011 at 9:12am
1. what is getting hghlighted when you get the error?
2. {Tbl_Objects_Fields.Primary?} is a text field, correct?
IP IP Logged
Karjoe
Newbie
Newbie
Avatar

Joined: 20 Oct 2011
Location: United States
Online Status: Offline
Posts: 5
Quote Karjoe Replybullet Posted: 20 Oct 2011 at 9:18am
Nothing gets highlighted.
 
Maybe I am not inserting the formula in the right place.  If you don't mind telling me if I am doing it correct
 
I right click on the text box (Primary?)
Select expert record
I change the drop down to Formula
I put the formula in the box next to the drop down
Click ok
 
Ismail
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Oct 2011 at 9:31am
ahh,
you are in the wrong place.
the select expert is used to include or excldue a row of data based on a boolean evaluation.
In the field explorer,
right click on the 'Formula Fields',
select New,
enter a name,
add your formula here
drag and drop the new formula field onto your canvas to view the results
IP IP Logged
Karjoe
Newbie
Newbie
Avatar

Joined: 20 Oct 2011
Location: United States
Online Status: Offline
Posts: 5
Quote Karjoe Replybullet Posted: 20 Oct 2011 at 9:51am
Sorry I wasted too much of your time.
 
I did all the above and I get this message
 
'A statement is expected here'
 
and the OK is highlighted.
Ismail
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Oct 2011 at 9:56am
there is a pick list option in the formula editor.
You curretnly have it set to "Basic syntax"
Change it to "Crystal Syntax"


Edited by DBlank - 20 Oct 2011 at 9:56am
IP IP Logged
Karjoe
Newbie
Newbie
Avatar

Joined: 20 Oct 2011
Location: United States
Online Status: Offline
Posts: 5
Quote Karjoe Replybullet Posted: 20 Oct 2011 at 10:03am
Worked now. thank so much for you help.
 
 
Ismail
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