Solved

Converting Name field into 3 Separate Fields in Crystal Reports

Posted on 2010-08-30
9
1,681 Views
Last Modified: 2012-05-10
My name field consists of one full name field, in this format: Last, First M.  I need to take this field and separate it into 3 different name fields: First Name Last Name and Middle Initial.  How do I do this in Crystal Reports V. 11?  Thanks for your time.
Regards
0
Comment
Question by:carolannp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 33563321
Try this

LastName formula
Split({YourNameField},",")[1]

FirstName Formula
Split(Split({YourNameField},",")[2])[1]

MiddleName Formula
Split(Split({YourNameField},",")[2])[2]

mlmcc

0
 
LVL 19

Expert Comment

by:GJParker
ID: 33565533
If the format you have shown is consistent then you can simply split the fields at the space i.e.

//@Lastname
Split({Table.Field}, ' ')[1]

//@FirstName
Split({Table.Field}, ' ')[2]

//@Initial
Split({Table.Field}, ' ')[3]

HTH
0
 

Author Comment

by:carolannp
ID: 33566662
If I try either above options to get the correct middle initial I get the following error when I actually run the report:
A subscript must be between 1 and the size of the array.  Thanks.
0
[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 
LVL 19

Expert Comment

by:GJParker
ID: 33566702
I take it you must have instances where no middle initial exists.

Try this for your initial formula
If Count(Split({Table.Field}, ' ')) >= 3 Then
      Split({Table.Field}, ' ')[3]
Else
      ''
it's probablu also a good idea to add the same test to the other 2 formulas as well, remembering to change teh test to >= 1 and >= 2

HTH
0
 

Author Comment

by:carolannp
ID: 33567189
Yes, you are correct in that some names don't have an initial, but your above example still isn't giving me the middle initial.  Example of names: Smith,John T.  There is a comma after Smith and a space after John.  Does this help?  Thanks.
0
 
LVL 19

Accepted Solution

by:
GJParker earned 250 total points
ID: 33567384
Try these :

//@FirstName
If Count(Split({Table.Field}, ',')) >= 1 Then
      Split({Table.Field}, ',')[1]
Else
      ''

//@LastName
If Count(Split({Table.Field}, ',')) >= 2 Then
      Split(Split({Table.Field}, ',')[2], ' ')[1]
Else
      ''

//@Initial
If Count(Split({Table.Field}, ' ')) >= 2 Then
      Split({Table.Field}, ' ')[2]
Else
      ''
0
 

Author Comment

by:carolannp
ID: 33568055
Still not quite right:
The above //@LastName and //@FirstName should be switched around.  I am getting the correct middle initial and the LastName, but the FirstName is containing the middle initial.
//@LastName
If Count(Split({staff_current_demographics.name},','))>=1 then
Split({staff_current_demographics.name},',')[1]
else
''
@FirstName
If Count(Split({staff_current_demographics.name},','))>=2 then
Split(Split({staff_current_demographics.name},',')[2],'')[1]
else
''
@Initial
if Count(Split({staff_current_demographics.name},' '))>=2 then
Split({staff_current_demographics.name}," ")[2]
else
''
Example FirstName: John T
Thanks.
0
 
LVL 19

Assisted Solution

by:GJParker
GJParker earned 250 total points
ID: 33568085
You misse dth espace out on the second line, where I have put the % sign should be a space

@FirstName
If Count(Split({staff_current_demographics.name},','))>=2 then
Split(Split({staff_current_demographics.name},',')[2],'%')[1]
else
''
0
 

Author Comment

by:carolannp
ID: 33568158
@FirstName I changed to:
If Count(Split({staff_current_demographics.name},','))>=2then
Split(Split({staff_current_demographics.name},",")[2])[1]
else
''
This works now.  All names are now separated correctly.  Thanks for your time.  I will close out this request.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question