nbotts
asked on
Removing middle name from name field
Hello,
I have a name field that lists names in the following manner: last,first middle
I need to change it so that it lists names like this: last, first
I am using the following to add a space between the last and first name, but am uncertain how to remove everything that follow after the first name:
NameWithSpacenoMiddle: Format(Replace([Name_Table .Name],"," ,", "),"""text""")
Thanks!
I have a name field that lists names in the following manner: last,first middle
I need to change it so that it lists names like this: last, first
I am using the following to add a space between the last and first name, but am uncertain how to remove everything that follow after the first name:
NameWithSpacenoMiddle: Format(Replace([Name_Table
Thanks!
ASKER
Thanks Cluskitt that generally works, but it does appear that some of the names do not have a middle name and when that is the case it throws an #Error.
Any way to control for if there is no middle name (and so I am assuming no space?
Any way to control for if there is no middle name (and so I am assuming no space?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
try this
NameWithSpacenoMiddle: Left([Name_Table.Name],InS tr([Name_T able.Name] ,",")) & " " & Mid([Name_Table.Name],InSt r([Name_Ta ble.Name], ",")+1,Tri m(InStrRev ([Name_Tab le.Name]," ")-InStr([Name_Table.Name] ,",")))
should give you
Last, First
NameWithSpacenoMiddle: Left([Name_Table.Name],InS
should give you
Last, First
to correct the error of missing space on some names
try this
NameWithSpacenoMiddle: Left([Name_Table.Name],InS tr([Name_T able.Name] ,",")) & " " & Mid([Name_Table.Name],InSt r([Name_Ta ble.Name], ",")+1,Tri m(InStrRev ([Name_Tab le.Name] & " "," ")-InStr([Name_Table.Name] ,",")))
should give you
Last, First
try this
NameWithSpacenoMiddle: Left([Name_Table.Name],InS
should give you
Last, First
ASKER
Thanks Cluskitt, that did the trick. Much appreciated!
ASKER
Thanks as well capricorn1.
Unfortunately the solution you provided still gave me an #Error whenever a middle name wasn't present.
Unfortunately the solution you provided still gave me an #Error whenever a middle name wasn't present.
Actually, his query should work for those with no space, but would generate an error for those without a comma (,)
Basically, instead of replacing the whole field, you're going to be replacing just the part of it that is to the left of the first space. This, however, assumes that you ALWAYS have a space in the field.