somanchivasu
Apr 21 2004, 01:20 PM
hi,
i just need help in figuring this one out I have a table with a Name field in which the last and first name are seperated by a comma(,) , now i want this data to go to other table as First name and last name in two different fields of other table how can i do this in microsofyt access.
thanks
srinivas somanchi
khaos
Apr 21 2004, 01:37 PM
For last name use
Left([WholeNameField],instr(1,[WholeNameField],",",1)-1)
For first name use
right([WholeNameField],Len([WholeNameField])-instr(1,[WholeNameField],",",1)-1)
This will work as long as you only have a first and last name in this field. If you have a middle name or initial then it will be a little more complex but doable.
HTH
Ken
somanchivasu
Apr 21 2004, 01:41 PM
thanks for the help let me try and see if it works out
khaos
Apr 21 2004, 01:41 PM
You're welcome, let me know if this works for you.
Ken
somanchivasu
Apr 21 2004, 01:44 PM
hi ,
i did not understand where to type in the code which you gave to get the result would you tell me elaborately,
thanks
khaos
Apr 21 2004, 01:51 PM
You can use that in the field location in query design view
like this in sql design view if you just want to copy/paste
SELECT Left([WholeNameField],instr(1,[WholeNameField],",",1)-1) AS LastName, right([WholeNameField],Len([WholeNameField])-instr(1,[WholeNameField],",",1)-1) AS FirstName FROM YourTableName
Just replace "YourTableName" with the proper table
HTH
Ken
somanchivasu
Apr 21 2004, 01:59 PM
i typed in the following:
SELECT Left([Name],instr(1,[Name],",",1)-1) AS LastName, right([Name],Len([Name)-instr(1,[Name],",",1)-1) AS FirstName
FROM vasutemp;
it gave this error:Wrong number of arguments used
somanchivasu
Apr 21 2004, 02:05 PM
Right([Name],Len([Name]-instr(1,[Name],",",1)-1) AS FirstName
FROM vasutemp;
I GUESS THERE IS SOMETHING WRONG WITH THE ABOVE LINE BECAUSE WHEN I REMOVE THAT PART FROM THE QUERY I GET THE LASTNAMES SEPERATED WITHOUT ANY PROBLEM
somanchivasu
Apr 21 2004, 02:11 PM
HI KEN!
THANKS FOR YOUR HELP EVERYTHING IS WORKING FINE NOW THANKS FOR YOUR HELP......
khaos
Apr 21 2004, 03:14 PM
You're welcome, glad to help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.