First Name Last Name


S

Scott McDaniel

I have a form to enter a First Name Last Name from a keypad on screen.
It works fine to input both First and last name into one field; however
is there a way that when I save the record I can split the first name
and the last name into seperate fields? I know I can enter them
seperatly but I'm trying to do it in one shot. Is there a function that
finds a space between two words, then perhaps another function to enter
whats left of the space, then another to enter whats on the right?
Any help is appreciated

You can use the InStr function to locate a space and then get everything to the Right and Left (using, quite
appropriately, the Right and Left functions) but what happens when someone enters a name like:

John L. Smith

Unless you specifically trap for that scenario, you'd end up storing either John L or L Smith as the First and Last
names. Granted, you could tell your users not to do this, but if you think they'll listen to you then you've got rocks
in your head <g>.

If you have a need to break the data into FirstName and LastName, then the only real foolproof method would be to have
a FirstName and a LastName field, and allow the user to enter those values ... even then, you'll have someone enter a
firstname of "John L.", and some else enter a last name of "L. Smith" ... but at least you can say "Hey, that's the way
the data was entered!".


Thanks
DS

Scott McDaniel
[email protected]_infotrakker.com
www.infotrakker.com
 
Ad

Advertisements

D

DS

I have a form to enter a First Name Last Name from a keypad on screen.
It works fine to input both First and last name into one field; however
is there a way that when I save the record I can split the first name
and the last name into seperate fields? I know I can enter them
seperatly but I'm trying to do it in one shot. Is there a function that
finds a space between two words, then perhaps another function to enter
whats left of the space, then another to enter whats on the right?
Any help is appreciated
Thanks
DS
 
F

fredg

I have a form to enter a First Name Last Name from a keypad on screen.
It works fine to input both First and last name into one field; however
is there a way that when I save the record I can split the first name
and the last name into seperate fields? I know I can enter them
seperatly but I'm trying to do it in one shot. Is there a function that
finds a space between two words, then perhaps another function to enter
whats left of the space, then another to enter whats on the right?
Any help is appreciated
Thanks
DS

Yes there is, somewhat, using the Instr, Left, Mid, and Right
functions, but don't even think of doing this intentionally!!!
Do not enter the full name in one field and then try and separate
them. How does Access know, for someone named Mary Anne van den Kamp,
which is the first name, the middle name or the last name?

If you do it correctly, right from the start, you'll save yourself
lot's of headaches. It's quite simple to concatenate 2 or 3 or more
separate fields together then it is to split them apart.
The correct Access method is to have a first name field, a middle
initial (or name) field, and a last name field.
 
B

Bob Quintal

I have a form to enter a First Name Last Name from a keypad on
screen. It works fine to input both First and last name into
one field; however is there a way that when I save the record
I can split the first name and the last name into seperate
fields? I know I can enter them seperatly but I'm trying to
do it in one shot. Is there a function that finds a space
between two words, then perhaps another function to enter
whats left of the space, then another to enter whats on the
right? Any help is appreciated
Thanks
DS
Yes, there is code, but consider the problems you can get
handling
names like Mary Kay Olsen and Jon Bon Jovi.

If you can guarantee that you will not ever have someone with a
space in their first name or a space in their last name,

Just put this in the [First Name] textbox
=Left([Full name],Instr(1,[Full Name," ")-1)
and this in the [last name] textbox
=Mid([Full name], Instr(1,[Full Name," ")+1)

Note that you will get an error on Madonna because there is no
space.
 
J

John W. Vinson

I have a form to enter a First Name Last Name from a keypad on screen.
It works fine to input both First and last name into one field; however
is there a way that when I save the record I can split the first name
and the last name into seperate fields? I know I can enter them
seperatly but I'm trying to do it in one shot. Is there a function that
finds a space between two words, then perhaps another function to enter
whats left of the space, then another to enter whats on the right?
Any help is appreciated
Thanks
DS

Use two fields. Or even five.

Consider the following people:

Rhoda Mae Jones <first name Rhoda Mae, and no, she doesn't like to be called
Rhoda>
John W. Vinson <first name John, middle initial W., last name Vinson>
Dr. Richard Kevin Smith, Jr. <his last name isn't Jr. or even Smith, Jr.>
Hans van Schmidt <last name van Schmidt>

John W. Vinson [MVP]
 
S

Steve

How are you going to enter Billy Bob Jones? First name is Billy Bob with a
space.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
Ad

Advertisements

D

DS

Scott said:
You can use the InStr function to locate a space and then get everything to the Right and Left (using, quite
appropriately, the Right and Left functions) but what happens when someone enters a name like:

John L. Smith

Unless you specifically trap for that scenario, you'd end up storing either John L or L Smith as the First and Last
names. Granted, you could tell your users not to do this, but if you think they'll listen to you then you've got rocks
in your head <g>.

If you have a need to break the data into FirstName and LastName, then the only real foolproof method would be to have
a FirstName and a LastName field, and allow the user to enter those values ... even then, you'll have someone enter a
firstname of "John L.", and some else enter a last name of "L. Smith" ... but at least you can say "Hey, that's the way
the data was entered!".






Scott McDaniel
[email protected]_infotrakker.com
www.infotrakker.com
Yeah your right about the client not listening. I'll keep it seperate.
Thanks
DS
 
Ad

Advertisements

D

DS

DS said:
I have a form to enter a First Name Last Name from a keypad on screen.
It works fine to input both First and last name into one field; however
is there a way that when I save the record I can split the first name
and the last name into seperate fields? I know I can enter them
seperatly but I'm trying to do it in one shot. Is there a function that
finds a space between two words, then perhaps another function to enter
whats left of the space, then another to enter whats on the right?
Any help is appreciated
Thanks
DS
Ok to make it short, Thank you for all of your replies and I guess I'll
just have to do seperate Fist Name - Last Name because otherwise this
could open a whole can of worms!
Thank You Everyone
DS
 

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