Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

switching the order of text in a string 3

Status
Not open for further replies.

jhieber

IS-IT--Management
Oct 23, 2003
5
US
Howdy all I am a crystal newbie so I am sure the answer to my question is easy but here goes.

I have a filed that is dbr_ name the filed is like doe,john L . I need to switch it to read n a report John L Doe.

Any help on this would be great
 
Create the following formula, replacing the "Doe, John L" with the field that contains your name.

stringvar input:="Doe,John L";
stringvar first;
stringvar last;
first:=trim(right(input,len(input)-instr(input,",")) );
last:=left(input,instr(input,",")-1);
first + " " +last

Mike
 
Dear Jhieber:

The instring function is your friend. There is probably a more elegant solution, but this is what I came up with quickly.

I tried to account for their not being any Middle Initial and a Last Name showing as for example Allen Lieberman (mine) which is not hypehnated but consists of a two word last name.

Let me know if you have issues:

stringvar name := {@sr}; //replace with your field

stringvar Lname := mid(name,1,InStr(1, name,',')-1) ;
stringvar Fname := if Instr( 1, name, '.') <> 0 then mid(name,InStr(1, name,',')+1, (InStr(name,'.')-2)) + &quot; &quot; else
mid(name,InStr(1, name,',')+1) + &quot; &quot; ;
stringvar MI := if Instr( 1, name, '.') <> 0 then mid(name,Instr( 1, name, '.')-1,2) + &quot; &quot; else &quot;&quot;;

fname + MI + Lname

Hope that helps,

ro

Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Ok...if your name is ALWAYS in this format- doe,john L -there is no problem

//@Name
WhilePrintingRecords;
stringVar temp := {Table.Name}
stringVar result;
numberVar position;

position := instr(temp,&quot;,&quot;);

result := right(temp, length(temp)- position) + &quot; &quot; + left(temp, position - 1);

result;




Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
One of many ways to skin this cat....

Name : {@RefomatName}
Formula : LeadingCaps (Mid ({Table.Name},(InStrRev({Table.Name},&quot;,&quot;)+1), (Length({Table.Name})- InStrRev({Table.Name},&quot;,&quot;))) + &quot; &quot; + Left ({Table.Name},(InStrRev({Table.Name},&quot;,&quot;)-1)))

REPLACE {Table.Name} with your &quot;name&quot; field.

It will handle the first letter in CAPS issue, and display your data as....

Name RefomatName
----------------------------------
doe,john L John L Doe
smith,jim Jim Smith

 
Dear Jim,

Very nice!*

jheiber,


Use Jim's formula, it is much more elegant, efficient, better .... and so on.

ro

Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Dear MJRBRIM,

Is that LeadingCaps function from a ufl? It is not in Crystal 8.5, just thought I would point that out.

Regards,

ro

Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
thank you Rosemary...a compliment from you is most appreciated

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top