Re: reformatting a name



The field with your full name is nf

nf = "smith, john m"

first name = Left([nf],InStr(1,[nf],",")-1)
middle initial = Right([nf],1)
last name = Mid([nf],InStr(1,[nf]," ")+1,InStrRev([nf]," ")-InStr(1,
[nf]," ")-1)

SQL:
SELECT
Left([nf],InStr(1,[nf],",")-1) AS first_name,
Right([nf],1) AS middle_initial,
Mid([nf],InStr(1,[nf]," ")+1,InStrRev([nf]," ")-InStr(1,[nf]," ")-1)
AS last_name
FROM Table1;

Cheers,
Jason Lepack


On Jan 30, 4:44 pm, buckpeace <buckpe...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
i have a field in a table that contains the name "smith, john m". (NOTE:
this name is all in one field...the 1st and last names are separated by a
comma, but the middle initial is not separated with a comma )

I need to put the name in 3 different fileds:
first name john
last name smith
middle initial m

Can anyone help me split up this name using an ACCESS Query????

I really appreciate it
--
Buck


.



Relevant Pages

  • Re: search free formated field
    ... John / Smith ... If the string contains one or more slashes ... Else if the string contains a comma ...
    (microsoft.public.access.modulesdaovba)
  • Re: put everything after comma, into next column?
    ... Check 'Comma'> Next ... > Smith, John (WCCS) ...
    (microsoft.public.excel.worksheet.functions)
  • RE: entering Jr or Sr, etc in name field....
    ... Judy" wrote: ... The problem is the import does not insert a comma after ... > name/last name fields so it shows as White, John or Smith, G for them. ...
    (microsoft.public.outlook.contacts)
  • entering Jr or Sr, etc in name field....
    ... The problem is the import does not insert a comma after ... name/last name fields so it shows as White, John or Smith, G for them. ... can't figure out where/how to change her display. ...
    (microsoft.public.outlook.contacts)
  • Re: InStr function
    ... in cases where the comma is not found because Instrwill return a 0. ... "Pete Provencher" wrote: ... >>> Smith, John A to John A Smith ...
    (microsoft.public.access.queries)