Queries

  • Thread starter Thread starter Kim Waters
  • Start date Start date
K

Kim Waters

How do I seperate a name field ex. "Doe, John" to put only
the last name in a seperate field?
 
-----Original Message-----
How do I seperate a name field ex. "Doe, John" to put only
the last name in a seperate field?
.
I would export the field into a text file then import it
back using the comma as a deliminator
 
If a comma consistently marks the end of your last name
field, you can use a combination of Left() and Instr()
with an update query to perform this.

I ran this in the immediate window:

? left("Doe, John", instr("Doe, John",",")-1)
Doe

You would replace "Doe, John" with your field name (e.g.,
[FullName]), and of course not use the "?" as part of your
expression.

A SQL statement incorporating this might look like:

Update tblYourTable Set [LastName] = left([FullName], instr
([FullName],",")-1)

------------

I have written a name parser that is designed to parse
very complicated name constructions. If you need this,
email me at (e-mail address removed), and I'll send it to
you. If others find this from a search engine and want it
(most requests for my name parser have come this way),
email me at (e-mail address removed).

David Atkins, MCP
 
Back
Top