473,394 Members | 1,641 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,394 software developers and data experts.

Splitting fields to last and First Name

I have a database where information is imported from another source. The other party sends 2 files that are imported. In the first file, they send employee information such as name, address, etc. The other file is automatic deductions that an employee makes monthly. I need to create a query that combines the two which I have no issue with. Here is the problem. The first file (Table) the name is split into 2 fields, and is just First and Last names with no "titles" (Jr Sr II III)the second file comes in as Lastname Jr, Firstname Middle initial (Smith Sr., John A.). I have split the fields and the query works but people with the tile in Last Name (Smith Jr.) are omitted.
Can I get rid of the title part of the name?

LastName: Left([Name],InStr([Name]," ")-1)

FirstName: Mid([Name],InStr([Name],",")+1)

It would be great if I could remove the Middle initial as well. Smith Jr., John A. becomes Smith John)

Thanks in advance.
Rich
Jun 9 '13 #1
8 6733
Rabbit
12,516 Expert Mod 8TB
Split it by the comma first to separate the last name and first name. Then take the result of that and split it by the space. So kind of what you have already but with an extra embedded call.
Jun 9 '13 #2
Unfortunately that did not work. When I do the initial split, I get the single names are ok but the ones with titles are still attached. When I split again by space, the single names are omitted and only the ones with tiles are present.
Jun 12 '13 #3
I have an access 2010 database where I import two tables from excel into 2 tables the database from a 3rd party. The first table is an employee list with demographic information and the fields are Last, First, Title, Address, Address 2, City, State, Zip, Telephone, and Hire Date. A new list is sent monthly, so Once the first set of records is in the table, the next step is an update query which adds new employees, updates former employees, as well as updates demographical information in the event of a change. The second table is a monthly import reporting biweekly deductions made by the employees from their payroll.

Here is my issue, The second table, (Dues Report), has fields that are sent as a combined name (Brown, Joe) With these individuals, I am either split the names on one table Left([Name],InStr([Name],",")-1) in one field and FirstName1: Mid([Name],InStr([Name],",")+1) in a second field. I can also due a name combine from the first table [Last] & ", " & [First] to cross reference table.

The second table come in with the combined names using titles and Initials (Smith III, Robert A.)

If I name combine From table one, Smith III, Robert A. <> Smith, Robert , If I Left([Name],InStr([Name],"," then Smith III, Robert still don't match.

I am willing to either Split the combined field to get just Smith Robert, or have the query find results from using Like so Smith III, Robert A. will match Smith, Robert.

I was willing to add the titles and initials to cure the problem, however every time I update the table with the new imported info, all my changes will revert to the original.

The Table "Employees" has everyone's demographic information. Every month I get a new list and then import into the database which in turn updates and adds to the employee list and then deletes all the records from the "Update Employees" table where the excel sheet was imported to so there is no redudancy in storage of data, just updates. If I change the records in the Last Name and First Name fields of the table by adding titles like Jr. and Sr. or initials like A. and B. so that the name combine will match the "Name" field in the second table, the next monthly update will revert the records to the original data and again will need to be manually updated.

Employee Table
Fields
Last ex. Brown
First ex. John
Address
Address 2
City
State
Zip
Date of Hire
NameCombine ex:Brown, John (Calculated)

duesreport Table
Fields
Name ex . Brown Jr., John C.
Dues Paid
Initiation Paid
Date Paid

I can use LastName1: Left([Name],InStr([Name],",")-1) which makes Smith, Bob just Smith but Brown Jr., John C. becomes Brown Jr. and not Brown.

I also tried the following after reading the forums:

SELECT duesreport.Name
FROM duesreport, employeelist
WHERE (((duesreport.Name) Like ([employeelist].[NameCombine] & "*")));

This works on all except those with Jr., Sr. on the end.
Jun 12 '13 #4
Rabbit
12,516 Expert Mod 8TB
Please show me how you attempted to implement my suggestion. Can't tell you what's wrong if I can't see it.
Jun 12 '13 #5
LastName1: Left([Name],InStr([Name],",")-1)
Same query
LastNamedone: Left([LastName1],InStr([LastName1]," ")-1) "Invalid Cell Call Error"

Created New Query
LastNamedone: Left([LastName1],InStr([LastName1]," ")-1)
Result-#Funct!
Jun 12 '13 #6
Rabbit
12,516 Expert Mod 8TB
You can't reference an alias that is created within the same level. Instead, embed the function calls in each other.
Jun 12 '13 #7
OK. How would you do that, I keep getting The expression you entered has a function containing the wrong number of arguments.

LastName1: Left([Name],InStr([Name],",")-1, Left([Name],InStr([Name]," ")-1))
Jun 12 '13 #8
Rabbit
12,516 Expert Mod 8TB
Something along the lines of
Left(Left([Name],InStr([Name],",")-1), InStr(Left([Name],InStr([Name],",")-1) & " ", " ")-1)
Jun 13 '13 #9

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

Similar topics

1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
0
by: Peter | last post by:
Using CDO 1.21 how do I get First Name and Last Name from Global Address Book? I have the following code where I retrieve LastName and FirstName in one field, but how do I get LastName and...
7
by: Mary | last post by:
I have a student who has a hyphenated first name. If I concatenate the name like this: StudentName:( & ", " & ), it works as expected. If, however, I try to get the first name first by...
4
by: rhepsi | last post by:
hii all, i have aproject where... wen i enter a text in the textbox..., accordingly it should search in teh first name and last name of the database and display the records How to search...
5
by: Jim in Arizona | last post by:
I built a webpage using vb.net (.net 2.0) that creates a form letter. This letter pulls data from a database. Although I populate the address with the person's full name, which comes from the name...
1
by: hbkiwi | last post by:
Hi, Just playing with Access fairly new to it (like days old). Also it's my first post here so if I'm in the wrong place, sorry.. What I'm wanting to know is basically I have lets call it Table...
9
by: mgstlucia | last post by:
I know that I saw code on this forum to put the Last Name, First Name in the same field when you start with a table that has 2 separate fields (LASTNAME and FIRSTNAME) but I can't find it. I...
4
by: samuel123 | last post by:
Greetings All, Once again back to this forum. I have got a problem and hope to get solution. Senario.. I have a table called users, it has following fields user_name ...
5
by: jmurphy | last post by:
What do i add to this script to validate the entry? Thanks in advance for the help. <form name="continue" method="POST" action="shipping1.asp" onsubmit="return validate_form ();"> <input...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.