PDA

Click to See Complete Forum and Search --> : [RESOLVED] Capitalize Suffix(Names) in Crystal


tuber
Feb 26th, 2009, 09:48 AM
How should I go about capitalizing Suffixes for names in Crystal.

John Smith IV not John Smith Iv

Right now the report is set up so it puts things in proper case, which obviously doesn't work in this case.

However, I'll also need to be able to handle:

John Smith Jr not John Smith JR

Can someone point me in the right direction? Please?

It would be a great birthday present for me :)

Thanks!!!!

VBFnewcomer
Mar 2nd, 2009, 02:28 AM
For a starter how do I know which words are to be Caps and which to be propercase. (Iam talking only of the lastname) :confused:

tuber
Mar 2nd, 2009, 10:40 AM
Okay, well, I guess I'll handle it with a long CASE statement.

However I'm not sure how to do this in Crystal. I know how to do the replace, just not how to get the Suffix.

I need to do Right I know this but then I need to grab all the character to the indexof(" ") a space delimiter. Which I don't know how to do.

So I'll need to set up a formula.

I need something likes this but I don't know how to use the right with an index of. I think I need to use the character key instead of " ", but I don't think Crystal has an IndexOf correct?





Select Right(Trim({Table.LastName}), Indexof(" "))
Case "IV"
: Replace({Table.LastName}, " iv", " IV")
Case "JR"
: Replace({Table.LastName}, " jr", " Jr")

techgnome
Mar 2nd, 2009, 12:48 PM
personally, it should have been stored in the DATABASE correctly in the first place. Report rendering isn't the place to be correcting bad data. Reports should display. At best, a few minor calculations, but there should be no data manipulation at all. If, how ever correcting the data isn't a solution, then maybe a correction to the driving query that feeds the report.

-tg

tuber
Mar 2nd, 2009, 01:49 PM
I completely agree with you on that. If only this was a database that we maintained it would be that way.

However, this is the solution I came up with. I'm still testing it but it seems to work.

Found on http://www.vbforums.com/showthread.php?t=492917&highlight=Index from brucevde.

Thanks everyone for the help!



stringVar array values;
numberVar index := 0 ;

values := split({Agent_Hierarchy.AgentLast});

for index := 1 to ubound(values) do
(

Select values[index]
Case "jr"
: values[index] := uppercase(left(values[index],1)) + lowercase(mid(values[index],2))



Case "iii"
: values[index] := uppercase(values[index])


Default
: values[index] := uppercase(left(values[index],1)) + lowercase(mid(values[index],2));

);


join(values)

tuber
Mar 3rd, 2009, 02:21 PM
Finished Code in case someone, somewhere needs to do this.

{@Full Name} = just another Formula that combines the First and Last Name. (First_Name + " " + Last_Name) Could have easily put it all in one.




stringVar array values;
numberVar index := 0 ;

values := split({@Full Name});

for index := 1 to ubound(values) do
(

Select values[index]
Case "jr"
: values[index] := ProperCase(values[index]) + "."

Case "sr"
: values[index] := ProperCase(values[index]) + "."

Case "ii"
: values[index] := uppercase(values[index])

Case "iii"
: values[index] := uppercase(values[index])

Case "iv"
: values[index] := uppercase(values[index])

Case "v"
: values[index] := uppercase(values[index])

Case "vi"
: values[index] := uppercase(values[index])

Case "vii"
: values[index] := uppercase(values[index])

Case "viii"
: values[index] := uppercase(values[index])

Case "ix"
: values[index] := uppercase(values[index])

Case "x"
: values[index] := uppercase(values[index])

Case "xi"
: values[index] := uppercase(values[index])

Case "xii"
: values[index] := uppercase(values[index])

Case "xiii"
: values[index] := uppercase(values[index])

Case "m.d."
: values[index] := uppercase(values[index])

Default
: values[index] := Propercase(values[index])

);


join(values)