Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Filter a string using a formula Post Reply Post New Topic
Author Message
crystal_newbiee
Newbie
Newbie


Joined: 23 Jul 2008
Online Status: Offline
Posts: 15
Quote crystal_newbiee Replybullet Topic: Filter a string using a formula
     Posted: 23 Jul 2008 at 3:27am
Hi everyone,
 
Im currently using Crystal reports 9, and was wondering if it was possible to create a formula field which filters a certain word from a string read in through a text file.  For example, im creating a reminder letter which displays the customers name at the top of it, but this sometimes starts with the text FAO, I still want this to appear there, but I want to use the same field for the "Dear customer Name" part of the letter without the FAO part showing.  I.e,
 
Top of letter would be:
 
FAO Mr peter smith - accountsletter1_txt.companyname (string)
address 1 
address 2
address 3
Postcode
 
 
23,07,2008
 
Dear Mr peter smith - @companyname (formula field)
 
I've tried a few things but am not actually sure whether this is possible.  Any help would be great.
 
Thanks
 
 
 
 
 
 
 
With power comes great responsibility!
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: 23 Jul 2008 at 4:48am
Hi Do you just want to replace FAO then use
 
replace('FAO Mr peter smith - accountsletter1_txt.companyname (string)','FAO','Dear')
 
 
i have used the sample string below for e.g. you will need to replace with {table.fieldname}
output
Dear Mr peter smith - accountsletter1_txt.companyname (string)
 
Cheers
Rahul
IP IP Logged
crystal_newbiee
Newbie
Newbie


Joined: 23 Jul 2008
Online Status: Offline
Posts: 15
Quote crystal_newbiee Replybullet Posted: 23 Jul 2008 at 5:00am
Thanks for your reply,
 
The FAO does not always appear within the customer name field.  So I just want to try and say:
 
IF accountsletter1_txt.companyname BEGINS 'FAO' - then display it after that.
ELSE
accountsletter1_txt.companyname.
 
I basically just dont want anything to appear there if the FAO part of the text is present.  Is that possible?
 
Thanks again for your help.
 
Kev
With power comes great responsibility!
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: 23 Jul 2008 at 7:04am

Hi use the code below

IF left('FAO Mr peter smith',3) = 'FAO' then
replace('FAO Mr peter smith - accountsletter1_txt.companyname (string)','FAO','Dear')
ELSE
'FAO Mr peter smith - accountsletter1_txt.companyname (string)'

Cheers
Rahul
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