Print Page | Close Window

Instr - Text Search

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=5423
Printed Date: 03 May 2024 at 2:03pm


Topic: Instr - Text Search
Posted By: NMGroup
Subject: Instr - Text Search
Date 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




Replies:
Posted By: JohnT
Date 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 ? 


Posted By: NMGroup
Date 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?



Posted By: rahulwalawalkar
Date 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


Posted By: NMGroup
Date 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


Posted By: rahulwalawalkar
Date 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


Posted By: NMGroup
Date Posted: 06 Feb 2009 at 3:28am
Sadly this still makes the name field blank?


Posted By: rahulwalawalkar
Date 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


Posted By: NMGroup
Date Posted: 06 Feb 2009 at 3:39am
nope does not like the formula with a < 1 needs a number boolean etc is expected!


Posted By: rahulwalawalkar
Date Posted: 06 Feb 2009 at 3:40am
Strange I am testing with xtreme database no errors here
 
can you mail me your report
 
mailto:rahulwalawalkar@yahoo.com - rahulwalawalkar@yahoo.com
 
Cheers
Rahul



Print Page | Close Window