Print Page | Close Window

Triming name problem

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=5213
Printed Date: 28 Apr 2024 at 7:15am


Topic: Triming name problem
Posted By: Krazy Kasper
Subject: Triming name problem
Date Posted: 14 Jan 2009 at 10:24am

The Order Rep Names in my ODBC table appear as follows, sometimes with all caps and sometimes not:

Lastname, Firstname OR Lastname, Mi. Firstname

I need to change them in my Crystal report to appear as follows with "normal" (first letter of each name capitalized:

Firstname Mi. Lastname

When I do the same thing in a VBA report my code is:

Function ParseFirstComp(OrderRepName) As String
ParseFirstComp = "" 'set the default return value
If Not IsNull(OrderRepName) Then
  Dim LPosition As Integer
  'Find postion of space
  LPosition = InStr(OrderRepName, " ")
  'Return the portion of the string before the space
  If LPosition > 0 Then
    ParseFirstComp = Left(OrderRepName, LPosition - 2)
  End If
End If
End Function

Function ParseSecondComp(OrderRepName) As String
ParseSecondComp = "" 'set the default return value
If Not IsNull(OrderRepName) Then
  Dim LPosition As Integer
  'Find postion of space
  LPosition = InStr(OrderRepName, " ")
  'Return the portion of the string after the space
  If LPosition > 0 Then
    ParseSecondComp = Mid(OrderRepName, LPosition + 1)
  End If
End If
End Function

And then in my query:

Trim ({OptimizeIt.OrderRepName}) ([Expr2] & "  " & [Expr1])

Can someone provide me the code so I can do the same in my Crystal Report? I expect I would put the code in a formula.

Thanks,

 Krazy (Bill) Kasper



-------------
Krazy Kasper



Replies:
Posted By: hilfy
Date Posted: 20 Jan 2009 at 2:20pm
This is actually very easy - Create a formula and use the ProperCase() function in Crystal.  From the Crystal Help file:
 
"ProperCase capitalizes the first letter of each word in the string and converts all other letters to lower case. It also capitalizes any letter that follows a non-alpha character.

Tip:    This function is particularly useful for capitalizing people's names correctly when they are stored as all capitals in a database."

-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: Krazy Kasper
Date Posted: 21 Jan 2009 at 5:17am
Thanks very much for your help.


-------------
Krazy Kasper


Posted By: Krazy Kasper
Date Posted: 27 Jan 2009 at 5:43am
OK, here's where I'm at.
 
The structure is lastname, firstname middleintital.
There is not always a middleinitial.

The code I'm using (follows) only gives me the middleinitial:

local StringVar Array Names1:=
Split({OptimizeIt.OrderRepName}, " ");
If UBound(Names1)=3 Then ProperCase(Names1[3]) Else " "


Changing it to the following only gives me the firstname:

local StringVar Array Names1:=
Split({OptimizeIt.OrderRepName}, " ");
If UBound(Names1)=2 Then ProperCase(Names1[2]) Else " "

Changing it to the following gives me nothing:
(You'd think it would give me the lastname):

local StringVar Array Names1:=
Split({OptimizeIt.OrderRepName}, " ");
If UBound(Names1)=1 Then ProperCase(Names1[1]) Else " "

Can someone help me put this all together so I get firstname middleinitial lastname (and no comma)?
Thanks.



-------------
Krazy Kasper


Posted By: hilfy
Date Posted: 27 Jan 2009 at 6:51am
Try something like this:
ProperCase(trim(Mid({OptimizeId.OrderRepName}, InStr({OptimizeId.OrderRepName}, ',') + 1)) + " " +
trim(left({OptimizeId.OrderRepName}, InStr({OptimizeId.OrderRepName}, ',') -1)))
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: Krazy Kasper
Date Posted: 27 Jan 2009 at 8:19am
Thanks. I'll give it a shot.

-------------
Krazy Kasper


Posted By: Saleem Muhammad
Date Posted: 25 Aug 2009 at 7:41am

Please help in getting the proper name format using propercase function for names like MCDONALD (should appear like McDonald)

Saleem


Posted By: Krazy Kasper
Date Posted: 25 Aug 2009 at 2:03pm
I have never seen any solution to the question you pose.
Perhaps one of the guru's can help.
 
 


-------------
Krazy Kasper



Print Page | Close Window