Instr - Text Search
Printed From: Crystal Reports Book — Forum Name: Technical Questions
Posted By: NMGroup — 5 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
Posted By: JohnT — 5 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 — 5 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 — 5 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 — 6 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 — 6 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 — 6 Feb 2009 at 3:28am
Sadly this still makes the name field blank?
Posted By: rahulwalawalkar — 6 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 — 6 Feb 2009 at 3:39am
nope does not like the formula with a < 1 needs a number boolean etc is expected!
Posted By: rahulwalawalkar — 6 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
|