My file has a text field that contains First Name space Middle Initial space
Last Name. I need to create new fields...one containing the First Name, one
containing the Middle Initial (if there is one), one containing the Last
Name. For instance:
Existing Field Data New First Name Data New Mid Init Data New Last Name
Data
Humphrey A Bogus Humphrey A Bogus
Hubert Smith Hubert
Smith
Is there a way to do this in Microsoft Access 2003?
Yes... but.
My friend Rhoda Mae's first name is Rhoda Mae, not Rhoda. Just ask
her.
My former coworker Dr. Felix de la Iglesia's last name is de la
Iglesia. His middle name is not "de".
There is NO easy and general way to do this, *even for a human being*
- if I saw the name "Wong Lee Fun" I'd simply have to ask the person
if their family name is Wong and their personal name Lee-Fun, Chinese
style, or if the family name is Fun.
That said... you can get rid of the COMMON cases using a series of
Update queries. Add your new FirstName, MidInit, and LastName fields
to your table. First run an Update query updating FirstName to
Left([ExistingField], InStr([ExistingField], " ") - 1)
and LastName to
Mid([ExistingField], InStr([ExistingField], " ") + 1)
To protect yourself from errors from names like "Cher" or "Madonna",
use a criterion of
LIKE "* *"
on the ExistingField.
Then, run a second update query; use a criterion of
LIKE "* *"
on LastName to include only two-word last names. Use the same kind of
Left and Mid logic as above, only on the LastName field, updating
MidInit and LastName.
THEN - run a Query searching for MidInit IS NOT NULL to find all the
"Mae" and "de" and "von" and so on, and fix them manually. It may be
necessary to ask the person (politely) what name they prefer.
John W. Vinson[MVP]