Hi Folks,
I have a name that is formatted in the following manner:
LN; FN MI
Example:
1. Smith; John Q (person has middle initial populated)
2. Smith; Jane (person does not have middle initial populated)
3. Jack III, Citizen (person has suffix after name with no middle initial populated)
4. John III, Citizen M (person has suffix after name with middle initial populated)
5. Johnson; Jane M. (person has middle initial populated but a period after the initial)
I am attempting to parse out the names using Instr, Mid, Right, Left, etc and need a little help please.
In trying to arrive at last name, I am using
Left([Name],InStr(1,[Name],";")-1)
which works nicely for all last names in all the situations that I can find.
In trying to arrive at the first name, I am using
Mid([Name],InStr(1,[Name]," ")+1)
which extracts the first name but includes the middle initial after the first name as well. I know that for the Mid statement I can instruct the command to stop grabbing characters but when I try to do so, it just doesn't work out. Because there is a space between first name and middle initial (when middle initial is populated), I can tell the Mid statement to stop grabbing characters after it hits the second space (since the first space is between the last name and first name and therefore must be ignored) ... but when I try to write that up, it doesn't return anything:
Mid([Name],InStr(1,[Name]," ")+1,InStr(InStr([Name]," ")," "))
Then there is the middle initial to contend with, which at this point if I cannot extract that part easily that is OK, but it would be nice.
Any help would be greatly appreciated.
Thank you,
Joe
I have a name that is formatted in the following manner:
LN; FN MI
Example:
1. Smith; John Q (person has middle initial populated)
2. Smith; Jane (person does not have middle initial populated)
3. Jack III, Citizen (person has suffix after name with no middle initial populated)
4. John III, Citizen M (person has suffix after name with middle initial populated)
5. Johnson; Jane M. (person has middle initial populated but a period after the initial)
I am attempting to parse out the names using Instr, Mid, Right, Left, etc and need a little help please.
In trying to arrive at last name, I am using
Left([Name],InStr(1,[Name],";")-1)
which works nicely for all last names in all the situations that I can find.
In trying to arrive at the first name, I am using
Mid([Name],InStr(1,[Name]," ")+1)
which extracts the first name but includes the middle initial after the first name as well. I know that for the Mid statement I can instruct the command to stop grabbing characters but when I try to do so, it just doesn't work out. Because there is a space between first name and middle initial (when middle initial is populated), I can tell the Mid statement to stop grabbing characters after it hits the second space (since the first space is between the last name and first name and therefore must be ignored) ... but when I try to write that up, it doesn't return anything:
Mid([Name],InStr(1,[Name]," ")+1,InStr(InStr([Name]," ")," "))
Then there is the middle initial to contend with, which at this point if I cannot extract that part easily that is OK, but it would be nice.
Any help would be greatly appreciated.
Thank you,
Joe