473,473 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Split column to make two indexs

114 New Member
Can a Access field let's say called FullName that contains a full name (first last). I I would like to create 2 new columns called FirstName and LastName using the the data in the FullName filed. Can this be done?

Thanks.
Dec 14 '06 #1
6 2855
NeoPa
32,556 Recognized Expert Moderator MVP
Yes. It can be done.
What do you need exactly?
There are many ways depending on exactly what you're after - display or update for instance.
Dec 15 '06 #2
ljungers
114 New Member
I'm trying to update the table. Table was loaded via import. The table has a field named FullName. Now I wish to add two more columns to the table. One called FirstName and the other called LastName.
I need to use the field with full to extract the first name and the last name.
exam: FullName="John Doe" then I want to use FullName to create FirstName=John LastName=Doe
Dec 15 '06 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
I'm trying to update the table. Table was loaded via import. The table has a field named FullName. Now I wish to add two more columns to the table. One called FirstName and the other called LastName.
I need to use the field with full to extract the first name and the last name.
exam: FullName="John Doe" then I want to use FullName to create FirstName=John LastName=Doe
Add two fields to the table FirstName and LastName. Now run the following update query.

Expand|Select|Wrap|Line Numbers
  1. UPDATE TableName SET FirstName = Left([FullName], InStr([FullName], " ") - 1), LastName = Right([FullName], InStr([FullName], " ") + 1);
  2.  
Mary
Dec 15 '06 #4
ADezii
8,834 Recognized Expert Expert
Can a Access field let's say called FullName that contains a full name (first last). I I would like to create 2 new columns called FirstName and LastName using the the data in the FullName filed. Can this be done?

Thanks.
'1) Add a [FirstName] Column to the underlying Table
'2) Add a [LastName] Column to the underlying Table
'3) Create an Update Query consisting odf the [FullName], [FirstName], and [LastName] Fields. In the [FullName] Field, set the criteria to Is Not Null
'4) In the Update to Row of [FirstName] enter the following:
Expand|Select|Wrap|Line Numbers
  1. Left([FullName],InStr([FullName]," ")-1)
'5) In the Update to Row of the [LastName] Field enter the following:
Expand|Select|Wrap|Line Numbers
  1. Right([FullName],Len([FullName])-InStr([FullName]," "))
NOTE: This will work fine as long as there are spaces between the First and Last names in the [FullName] Field and there are no middle initials in the [FullName] Field. If either one of these conditions exist, the situation becomes a little more complex. Hope this helps...
Dec 15 '06 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
'1) Add a [FirstName] Column to the underlying Table
'2) Add a [LastName] Column to the underlying Table
'3) Create an Update Query consisting odf the [FullName], [FirstName], and [LastName] Fields. In the [FullName] Field, set the criteria to Is Not Null
'4) In the Update to Row of [FirstName] enter the following:
Expand|Select|Wrap|Line Numbers
  1. Left([FullName],InStr([FullName]," ")-1)
'5) In the Update to Row of the [LastName] Field enter the following:
Expand|Select|Wrap|Line Numbers
  1. Right([FullName],Len([FullName])-InStr([FullName]," "))
NOTE: This will work fine as long as there are spaces between the First and Last names in the [FullName] Field and there are no middle initials in the [FullName] Field. If either one of these conditions exist, the situation becomes a little more complex. Hope this helps...
ADezii is of course right use his code for the LastName instead of mine.

Mary
Dec 15 '06 #6
NeoPa
32,556 Recognized Expert Moderator MVP
A (slightly) better version for the Surname field would be
Expand|Select|Wrap|Line Numbers
  1. Mid([FullName],InStr([FullName]," ")+1)
The reason I asked the question (thanks for the reply btw) was mainly to determine whether display or update, but also for you to have a careful think about what rules the data MUST adhere to.
If you can say, hand on heart, that there will never be an exception to the format {Firstname}SPACE{Surname} then this will work for you.
Otherwise, you may be better advised to create a global function which handles all cases for you. It would need to handle returning both names individually.
Dec 15 '06 #7

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

Similar topics

2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
0
by: Cecil Brand | last post by:
Hi, I was wandering is there an easy way to rebuild indexs on tables I have the .frm and .MYD files. I read in the mysql manuals about backup_tables and Restore_table that rebuild the index...
2
by: needin4mation | last post by:
Hi, thanks for any help here: SqlCommand cmd = new SqlCommand("SELECT categories FROM catalog" conn); rdr = cmd.ExecuteReader(); String temp; while (rdr.Read()) { temp = rdr;...
4
by: thiago_bagua | last post by:
Hi all, I have a csv file exported from excel. On cells where there was a comma in the text, it wraps the character with double quotes. For example: Column 1,"column two, and some more...
3
by: ashok | last post by:
Hi, I need a function that will divide text from mysql in 2 parts, so that I can display first half in one column and second half in second column. I can't find what function will do this job....
2
by: Dscar | last post by:
Hi, I am a beginner in ACCESS, I've imported data into access, and then realized that I need to split the information in one of my columns into 2 columns. the information looks like this:...
16
by: randallc | last post by:
Hi, I need to take an input of 1D array, each item pipe delimited, and make a 2D array for column sorting.. Can anyone please help as my first ady with jscript, and haven't a clue why i get this...
4
by: Gilberto | last post by:
Hello, I have a couple of forms using the code to FIND AS YOU TYPE from Allen Browne (http://allenbrowne.com/AppFindAsUType.html). It worked PERFECTLY until yesterday when i splitted the db into...
2
by: naveen322 | last post by:
what is the use of views, indexs and view and materialized view & index and bit map index
9
by: kwerkyone | last post by:
I have two separate but similar databases and each has a split form that acts as the main form used. One of these split forms is able to be filtered from the datasheet portion of the split form using...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.