Reversing name order

W

W. Guy Delaney

In my database, I have the names of the parents of my children entered with
the last name first followed by their first name. For instance: Johnson,
Calvin & Dorothy

In some instances, I need to have the names in reverse order, such as Calvin
& Dorothy Johnson.

How can I enter a formula in my query to accomplish this reversal.
 
J

John Vinson

In my database, I have the names of the parents of my children entered with
the last name first followed by their first name. For instance: Johnson,
Calvin & Dorothy

In some instances, I need to have the names in reverse order, such as Calvin
& Dorothy Johnson.

How can I enter a formula in my query to accomplish this reversal.

The need to do this (and the need to be able to search efficiently on
lastnames, firstnames or both) is why most developers prefer to store
surnames in one field, and given names in another; it's easier to put
them together using a calculated field like

FullName: [LastName] & ", " & [FirstName]

or

FullName: [FirstName] & " " & [LastName]

However, given your structure, you can use a rather snarky string
expression:

Trim(Mid([namefield], InStr([namefield], ",") + 1) & " " &
Left([namefield], InStr([namefield], ",") - 1)

A question: given that it's the 21st century, what do you plan to do
if the child's parents are "Mark Jones and Jane Smith"? Not all
parents marry, and of those that do, not all women take their
husband's last name!
 

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