How do I sort one column by the second word in that column?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a person's name in one column eg: Ginny Roby. I need to either sort
by Roby or divide the column into two separate names 1: Ginny 2: Roby. Can
this be done?
 
I have a person's name in one column eg: Ginny Roby. I need to either sort
by Roby or divide the column into two separate names 1: Ginny 2: Roby. Can
this be done?

I'd suggest dividing. Create two new fields, FirstName and LastName.
Run an Update query updating FirstName to

Left([name], InStr([name], " ") - 1)

and LastName to

Mid([name], InStr([name], " ") + 1)

Then you'll need to run a Query using a criterion of

LIKE "* *"

on LastName; you very likely have people with names like "Billy Bob
Thornton" who will end up with "Bob Thornton" in the LastName (his
first name is Billy Bob, just ask him). Names like "Ludwig von
Beethoven" will be handled correctly though.

John W. Vinson[MVP]
 
It would be much easier to learn how to do this using Excel. Put a few
funny names in the first column, and use the command left, right, and
concatenate. Each of those things has nice help screens which would tell
you how to do it. It would be fast, and then, when you know what you are
doing,do the same thing in Access.
John Vinson said:
I have a person's name in one column eg: Ginny Roby. I need to either
sort
by Roby or divide the column into two separate names 1: Ginny 2: Roby.
Can
this be done?

I'd suggest dividing. Create two new fields, FirstName and LastName.
Run an Update query updating FirstName to

Left([name], InStr([name], " ") - 1)

and LastName to

Mid([name], InStr([name], " ") + 1)

Then you'll need to run a Query using a criterion of

LIKE "* *"

on LastName; you very likely have people with names like "Billy Bob
Thornton" who will end up with "Bob Thornton" in the LastName (his
first name is Billy Bob, just ask him). Names like "Ludwig von
Beethoven" will be handled correctly though.

John W. Vinson[MVP]
 

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

Back
Top