Hello!
I inherited a database in Access 2000 with the employee
names listed as Firstname Lastname. Is there an easy way
to convert that data to Lastname, Firstname.
Ie: Change Gary Weiss to Weiss, Gary.
Thanks in advance!
Gary
This is why most developers will have separate fields for first and
last names: it's much easier to concatenate two fields than to
separate a single field, and it makes it much easier to (say)
alphabetize a list by last name. Some of the problems you'll
encounter:
Joe Bob Smith ' what's his first name? Everyone calls him Joe Bob
Mark van Kleef ' but he's Mark, last name van Kleef
That said - you can get the simple two-name cases turned around using
Access' string functions:
TurnedName: Trim(Mid([EmpName], InStr([EmpName], " "))) & ", " &
Left([EmpName], InStr([EmpName], " "))
You can (and probably should!) add new FirstName and LastName fields
to your table; run an Update query updating FirstName to
Left([EmpName], InStr([EmpName], " ") - 1)
and LastName to
Trim(Mid([EmpName], InStr([EmpName], " ")))
and then fix up the Joe Bob and other special cases.