I have a table with a concatenated name field that I need to separate into First, Last, and MI in a query. The problem is one of inconsistent data entry. Here are some samples:
Name
BELL,FRED J
BLACK,MATTHEW
PLUMBERG, ANDY
BEALS IV,JOHN C
Here are the strings I am using:
Last Name: Left([Name],InStr([Name],",")-1)
First Name: Mid([Name],InStr([Name],",")+1,InStr([Name] & " "," ")-(InStr(([Name]),",")+1))
Middle Initial: Mid([Name],InStr([Name] & " "," ")+1,1)
These statements work perfectly on names like the first 2 examples, however if a name happens to have a space after the comma it fails to get the first name and puts the first letter of the first name as the middle initial. Also if the name has a "III" or "IV" as in the last example I get a "#Error" for first name and the "I" in "IV" as a middle initial. Can you help me take care of these possibilites in my extractions? Thanks in advance!
Name
BELL,FRED J
BLACK,MATTHEW
PLUMBERG, ANDY
BEALS IV,JOHN C
Here are the strings I am using:
Last Name: Left([Name],InStr([Name],",")-1)
First Name: Mid([Name],InStr([Name],",")+1,InStr([Name] & " "," ")-(InStr(([Name]),",")+1))
Middle Initial: Mid([Name],InStr([Name] & " "," ")+1,1)
These statements work perfectly on names like the first 2 examples, however if a name happens to have a space after the comma it fails to get the first name and puts the first letter of the first name as the middle initial. Also if the name has a "III" or "IV" as in the last example I get a "#Error" for first name and the "I" in "IV" as a middle initial. Can you help me take care of these possibilites in my extractions? Thanks in advance!