Parse Full Name to First, Middle, Last Similar to Outlook Procedur

J

JonMulder

I'm looking for code to can parse a full name into its individual
components. I have found an example in a good book (Beginning Access 97 by
Smith and Sussman) so am familiar with the general basics of parsing a string.
The Outlook software does a great job of parsing fairly complicated
strings. For example, it breaks "John and Mary Smith" into:
First name: John and Mary
Last name: Smith
In addition, I want to include "Trustees" as an acceptable suffix. (That
should be fairly easy to do, I think.)
Can anyone point me to some code to emulates the Outlook functionality of
parsing a name?
Thanks,
Jonathan Mulder, Red Bluff, CA
 
T

Tim Ferguson

Can anyone point me to some code to emulates the Outlook
functionality of
parsing a name?

Look up help for Instr() and RevInstr() functions...
You might also want to take in Split() and Join() too...

HTH

Tim F
 
K

Klatuu

Jon,
This is an age old problem and I have done it in about 3 or 4 different
languages. The basics are not that hard, but the problem you will run into
is prefixes, suffixes, middle initials or names, last names that are two
words (Von Trump), etc.
I don't have a VBA version, so I can't send you any code, but just make you
aware of some traps. Some other problems you might hit:
Someone entered more that one space between names. Names with punctuation.
Milford P. Groumper, Esq.
Don-L Muier (A real person)
Towns VanZandt

It gets tricky, but I'll bet someone out there has something like Outlook
does it.
Good Luck
 
J

JonMulder

Don,
Thanks for the response and caution. Yes, I realize that there are a lot
of pitfalls involved in it. I had been hesitant to try to tackle it. The
code I've looked at starts to get pretty specific, particularly for prefixes
and suffixes. For example, when I typed in "Jon Mulder, Trustee" in the
Outlook name field, it stored it as:
Last name: Jon Mulder
First name: Trustee
If the codes knows that "trustee" is an acceptable suffix, it would parse
it correctly. Hopefully, someone can point me to some pretty good code;
otherwise, I'll go with what I've pulled from the book and modify that.
Jon Mulder Red Bluff, CA
 
J

John Nurick

For reasons that others have pointed out, this is not just a dificult
programming task but an impossible one to get 100% right. As always,
there's a trade-off between your time and your budget.

If you have a budget, you might like to take a look at commercial
software such as Splitter (http://www.infoplan.com.au). If you want to
write code and learn, now's a good excuse to get into regular
expressions...
 
T

Tim Ferguson

If you want to
write code and learn, now's a good excuse to get into regular
expressions...

There was a wonderful quotation hereabouts recently:

If you have a problem and need to solve it with
regular expressions, then you have two problems...


All the best


Tim F
 
J

John Nurick

There was a wonderful quotation hereabouts recently:

If you have a problem and need to solve it with
regular expressions, then you have two problems...

I'd rather spend two hours on a regex than all day on a hundred lines of
code<g>. IMHO there's a real saving there - but regexes need to be
tested and commented just as thoroughly as any other sort of code.

ATB
John
 

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