Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: "Contains" as a formula Post Reply Post New Topic
Author Message
andy.jay
Newbie
Newbie


Joined: 15 Feb 2011
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote andy.jay Replybullet Topic: "Contains" as a formula
    Posted: 15 Feb 2011 at 4:19am
Hi folks,

I'm trying to write a formula which will inform me if certain text is within a field i.e.
if XXXXXX contains "GR" then "GR" else "0"

I know contains isn't valid but does anyone know what I could substitute in its place and get the same result?

Tanks in advance,

AJ
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Feb 2011 at 4:28am
instr()
or
like
if instr({table.field},"GR")>0 then "GR" else "0"
 
if {table.field} like "*GR*" then "GR" else "0"
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Feb 2011 at 4:29am
note that instr() is case-sensitive by default but can be changed

Edited by DBlank - 15 Feb 2011 at 4:31am
IP IP Logged
andy.jay
Newbie
Newbie


Joined: 15 Feb 2011
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote andy.jay Replybullet Posted: 15 Feb 2011 at 4:46am
Excellent, many thanks for that. After 6 years using Crystal, it never surprises me when I learn something new :-) Many chunks of hair saved from my scalp :-)
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.018 seconds.