split name field into parts (1 Viewer)

supmktg

Registered User.
Local time
Today, 12:25
Joined
Mar 25, 2002
Messages
360
I'm trying to build a query function to split a [FullName] Field in a table into it's parts--[Prefix], [FirstName],[Middle],[LastName],[Suffix] in the same table. Unfortunately, the [FullName] comes to me in many different configurations:

"John Smith"
"John M. Smith"
"Mr. John Smith"
"John Smith, MD."
"Mr. & Mrs. John Smith"
"John and Mary Smith"
"John Smith and Mary Ann Wilson-Smith"
"John M. Smith and Mary Ann Wilson"
"Dr. Mary and Mr. John Smith"

,etc.

So far, I'm looking for " and " or " & " to determine if there's one name or two, and looking for "-" or "," to determine if there's a hyphenated name or a suffix. Am I on the right track, or is there a better way to start?

Can someone point me in the right direction?

Thanks,
Sup
 

RV

Registered User.
Local time
Today, 18:25
Joined
Feb 8, 2002
Messages
1,115
You're on the right track meaning you'll need a single approach per instance.

RV
 
F

funk_green

Guest
Having just tried the code, I thought I should let you know what I found.

The name formats I was splitting was SURNAME then INITIALS with only spaces...no commas.

Because the format is reversed, I had to use the get_title to extract the surname and the get_surname for the initials. Everything works well except for surnames with multiple parts such as Van Der Bilt.

To fix that, run a query using Len() to determine the length of the original full name field, with criteria

<>Len([Surname])+Len([Initials])+1

which creates a numeric value based on length of initials plus surname plus the space between.
 

Users who are viewing this thread

Top Bottom