473,320 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Seperate Name field into three seperate fields

I am working with an ACCESS query that has a field called PR_EMP_NAME. This field contains an employee’s last name, first name and middle name. I need to separate this field into three separate fields. I have been able to separate the field into the last and middle names but can’t figure out how to get the first name which is in between the last and middle names. All names are separated by a space. I am using the following to obtain the Last and Middle names. Any ideas how I can get the first name?
Expand|Select|Wrap|Line Numbers
  1. LastName: Trim(Left([PR_EMP_NAME],InStr(1,[PR_EMP_NAME]," ")))
Expand|Select|Wrap|Line Numbers
  1. MiddleName: Right([personnel]![PR_EMP_NAME],Len([personnel]![PR_EMP_NAME])-InStrRev([personnel]![PR_EMP_NAME]," "))
Expand|Select|Wrap|Line Numbers
  1. FirstName ?????
May 6 '10 #1

✓ answered by gershwyn

Try this:
Expand|Select|Wrap|Line Numbers
  1. FirstName: Trim(Mid([PR_EMP_NAME],InStr(1,[PR_EMP_NAME]," "),InStrRev([PR_EMP_NAME]," ")-InStr(1,[PR_EMP_NAME]," ")))
This will consider everything between the first space and the last space in the name to be the "middle" name. That should work as you've described your source data; if it doesn't then please post some examples for us to work with and we can modify the function a bit.

Hope that was helpful, and welcome to Bytes. :)

2 2593
gershwyn
122 100+
Try this:
Expand|Select|Wrap|Line Numbers
  1. FirstName: Trim(Mid([PR_EMP_NAME],InStr(1,[PR_EMP_NAME]," "),InStrRev([PR_EMP_NAME]," ")-InStr(1,[PR_EMP_NAME]," ")))
This will consider everything between the first space and the last space in the name to be the "middle" name. That should work as you've described your source data; if it doesn't then please post some examples for us to work with and we can modify the function a bit.

Hope that was helpful, and welcome to Bytes. :)
May 6 '10 #2
Thanks this did it.
May 6 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: ND | last post by:
I need to create a separate field from 4 fields, "street address", "city", "State" and "zip code". For example, Street address - 100 Forest Street City - Seattle State - WA Zip - 05555 ...
1
by: Tony | last post by:
Hi, I have an ID text field that is composed of two alphabetical letters and the rest are numbers. This field is also a primary key. In this same table, I want to separate this field into two...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
1
by: Grex | last post by:
I have a table with about 20 fields. There is a name field that is populated repeatedly with the same names over and over. Let's say 1000 records, and 25 names. Each name is in there 40 times. I...
2
by: CollierC | last post by:
I need to write a query that manipulates a name field from "firstname lastname" to "lastname, firstname". I have read multiple solutions to split firstname and lastname to separate fields,...
4
by: NeilIanBaker | last post by:
Hello I am trying to select the first name and surname from a name field where the name is in the form of; eg. Mrs Marilyn Payne Mrs Mary Swanton Ms EM Lomas Lt Col R...
14
by: adamjblakey | last post by:
Hi, I have a function here: var AdminResponse = ""; function parseResponse(){ var nText = AdminResponse.getElementsByTagName('optionText');
1
MindBender77
by: MindBender77 | last post by:
Hello Again All, I have a memo field that is backslash delimited. I am attempting to break up this field into individual fields. Ex (memo field). \John L. Doe\\StreetName RD\\City, Pa 11111 ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.