Separating Names

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a field that contains that is in the following format:
[lastname],[firstname] (no spaces)

I need to somehow separate the two and put the lastname into a field called
Last and the firstname into its own separate field called first. Is there
some magical code that will accomplish this?
 
Melanie said:
I have a field that contains that is in the following format:
[lastname],[firstname] (no spaces)

I need to somehow separate the two and put the lastname into a field called
Last and the firstname into its own separate field called first. Is there
some magical code that will accomplish this?


You can use InStr function to find the comma. Then Left and
Mid to get the two parts:

LastName: Left(fullname, InStr(fullname, ",") - 1)
FirstName: Mid(fullname, InStr(fullname, ",") + 1)
 
Back
Top