Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Instr - Text Search Post Reply Post New Topic
Author Message
NMGroup
Newbie
Newbie
Avatar

Joined: 05 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote NMGroup Replybullet Topic: Instr - Text Search
    Posted: 05 Feb 2009 at 6:48am

Hello

I have a field called name. Users have have put some text at the end of this text ie SELF

What I need to do is look in this field and if this exists display this. what I have so far that does not work as it displays nothing in the field is -

If Instr ({detor.name},'SELF') >0 Then {debtor.name}

Is there a way I can make this work?

Thanks In Advance

IP IP Logged
JohnT
Groupie
Groupie
Avatar

Joined: 20 Jan 2008
Online Status: Offline
Posts: 92
Quote JohnT Replybullet Posted: 05 Feb 2009 at 8:51am
I'm not sure I understand your problem.  I haven't tested it but I think the formula will not display anything if the word 'SELF' is not part of the field called name.  Is that what's happening ?  If the word 'SELF' is part of the field called name, it should simply display the value in name.  Don't forget that INSTR is case sensitive if you don't use the compare argument.  What do you want to do if the string 'SELF' is not found ? 
IP IP Logged
NMGroup
Newbie
Newbie
Avatar

Joined: 05 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote NMGroup Replybullet Posted: 05 Feb 2009 at 8:57am

Ok Example

name=thiscompanyisltdSELFBILL

What I am trying to do is search the field name for 'SELFBILL' and display this on the report. If the text does not contain 'SELFBILL' I do not want this on the report!

Does that make sense?

IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 05 Feb 2009 at 9:31am
Hi
 
Use the instr function as below
 
Instr({Table.fieldname},'SELFBILL')
 
This will give you number as output,so in your record selection formula you can check
 
 
Instr({Table.fieldname},'SELFBILL') > 0
 
so it will return all records which have text SELFBILL in them
 
 
 
Cheers
Rahul
IP IP Logged
NMGroup
Newbie
Newbie
Avatar

Joined: 05 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote NMGroup Replybullet Posted: 06 Feb 2009 at 12:41am
I will have a plat with this. What I was after was if 'SELFBILL' exsists then display the whoe field {detors.name}
 
Thanks for the help
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 06 Feb 2009 at 3:19am
Hi
 
You can check if
 
Create a formula
 
Frm
 
Instr({detors.name},'SELFBILL') > 0
 
this will give result of True or False .
 
Then follow the steps below
 
In your report click detors.name field then format field ,then select common tab in format editor then click x+2 against Suppress
 
and enter the code
 
@Frm = False
 
Cheers
Rahul
IP IP Logged
NMGroup
Newbie
Newbie
Avatar

Joined: 05 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote NMGroup Replybullet Posted: 06 Feb 2009 at 3:28am
Sadly this still makes the name field blank?
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 06 Feb 2009 at 3:35am
Hi
 
You can check if
 
Create a formula
 
Frm
 
Instr({detors.name},'SELFBILL') 
 
this will give retrun number value
 
Then follow the steps below
 
In your report click detors.name field then format field ,then select common tab in format editor then click x+2 against Suppress
 
and enter the code
 
@Frm < 1
 
let me know if this works
 
Cheers
Rahul
IP IP Logged
NMGroup
Newbie
Newbie
Avatar

Joined: 05 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote NMGroup Replybullet Posted: 06 Feb 2009 at 3:39am
nope does not like the formula with a < 1 needs a number boolean etc is expected!
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 06 Feb 2009 at 3:40am
Strange I am testing with xtreme database no errors here
 
can you mail me your report
 
 
Cheers
Rahul


Edited by rahulwalawalkar - 06 Feb 2009 at 3:43am
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.