splitting field into 2

S

Sillie_J

I am working with Access tables given to me by a client and incorporating
their data into a larger database. The old tables have the first name and
last name in one field, which most of us know it's a no-no in database world.
The last name is first, followed by a comma (no space), then the first name.
Here's an example, "Smith,John".

How can I separate the last name into its own field and likewise for the
first name? The lengths of the names vary, so it's not possible to specify
the number of characters in using Left, Mid, or Right coding. Is there a way
to use the comma as a separator?

Thank you!
 
S

Sillie_J

Perfect!! Thank you!!!! Now I just have to figure out how to put the "Jr."
that occurs after the first name into the last name field after the last name
(e.g., Smith,John Jr.) Whoever created this db table before was not
well-versed... I should be able to figure it out based on the expressions
available on the website you provided. Thanks again.

Jill
 
F

fredg

Perfect!! Thank you!!!! Now I just have to figure out how to put the "Jr."
that occurs after the first name into the last name field after the last name
(e.g., Smith,John Jr.) Whoever created this db table before was not
well-versed... I should be able to figure it out based on the expressions
available on the website you provided. Thanks again.

Jill

If you are using Access 2000 or newer, look up InStrRev() in VBA Help.

Title:
IIf(InStr([CombinedNames],"Jr."),Mid([CombinedNames],InStrRev([CombinedNames],"
")+1),"")

The above will work even if the First Name position includes a space,
i.e.
Sands,Henry Alan Jr.
Sands,H. S. Jr.

Is Jr. the only title you have? What about Sr., Dr., PhD., Ms., etc.
 
N

nanne

Sillie

Save the fields id, Name from old db file als ASCII file with comma as field
separtor. Import the ASCII file into the new db in a new table. relate both
tables on id and use replace name into last name and first name into a new
field First Name

regards

Nanne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top