473,808 Members | 2,835 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Last Name, First Name

30 New Member
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 have a table where the first name and last name are in two separate fields and I want to change the table to put both fields together in a field (MEMBER).

Do I do this using an update query?

Thanks
Mar 13 '08 #1
9 16821
Stewart Ross
2,545 Recognized Expert Moderator Specialist
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 have a table where the first name and last name are in two separate fields and I want to change the table to put both fields together in a field (MEMBER).

Do I do this using an update query?

Thanks
Hi. As the answer to the post you refer to said, you do not need to update any field at all, nor do you need to store the combined name in a new field. The combined name is just a calculated field - in this case one which is concatenated from two field values and a string constant.

In the Access graphical query builder add the fields you need from the table, and in a blank column within the grid add a calculated field like this:
Expand|Select|Wrap|Line Numbers
  1. NAME: [LASTNAME] & ", " & [FIRSTNAME]
  2. or
  3. NAME: [FIRSTNAME] & " " & [LASTNAME]
In SQL this is just
Expand|Select|Wrap|Line Numbers
  1. SELECT ([FIRSTNAME] & " " & [LASTNAME]) AS NAME FROM [YourTable];
-Stewart
Mar 13 '08 #2
Scott Price
1,384 Recognized Expert Top Contributor
To add to what Stewart has said, having Last Name and First Name in separate columns in your table conforms to proper database design rules which exist for specific reasons. To combine them into one field breaks the rules, which will make you pay later... One example is when you want to sort your table alphabetically by last name... If the names are in one field you are faced with a headache of having to first split the field, sort by the last name, then recombine. With proper design it's far simpler to first sort, then combine on the fly.

Regards,
Scott
Mar 14 '08 #3
mgstlucia
30 New Member
Thank You for your reply. I'm confused as to where I would use the calculated field. Do I put this in the table or a form where I want to bring the two fields together?

For example:

The ORDER FORM form, where I want the name, address, etc. Do I put the code somewhere in the Name properties?
Thanks
Mar 15 '08 #4
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Thank You for your reply. I'm confused as to where I would use the calculated field. Do I put this in the table or a form where I want to bring the two fields together?

For example:

The ORDER FORM form, where I want the name, address, etc. Do I put the code somewhere in the Name properties?
Thanks
Hi. My reply referred to a query based on your table, as you can add calculated fields to any query. You do not have to change the design of your table, as Scott also pointed out.

If you want, you can add a calculated field to your form without going through the query step. Open the form in design view, and from the controls toolbox add a new, blank, textbox to your form. In the new control's controlsource property type
Expand|Select|Wrap|Line Numbers
  1. =[Firstname] & " " & [Lastname]
There are many good introductory books on Access which will help you understand the uses of tables, queries and forms. Try out some of the examples you will find in any such book to get a better idea of what Access is about.

-Stewart
Mar 15 '08 #5
mgstlucia
30 New Member
I went back to my friend's college book on Access and tried a calucated field example and I now know where I went wrong, but I'm using this Name field in a combobox.

In the controlsource of my Name combobox I have =[LastName] & ", " & [FirstName]. That works fine, but it only show me the first record in my table and when I try to select another name it does not change.

The form I am creating is an Order Form which will pull Customer info and Product info in a subform. I will be autofilling the address info which I think I know how to do.

Before I started creating a database with the real info, I played around with dummy info but used the Name field with the first and last name together.

I have the Access for Dummies, the Form & Reports for Dummies and my friend's college book as reference. Believe me when I say, I reread the sections alot before posting a question here...LOL. I appreciate your patience and all the advice you have given me thusfar.

Thanks
Mar 15 '08 #6
Scott Price
1,384 Recognized Expert Top Contributor
You can do the same thing in your query. Then tie the text box to the field in the query just as you would any other query field.

Make sure you form's record source is the query.

In a blank field of the query in design view type something like this:
Expand|Select|Wrap|Line Numbers
  1. Name: [FirstName] & " " &  [LastName]
Regards,
Scott
Mar 15 '08 #7
missinglinq
3,532 Recognized Expert Specialist
One example is when you want to sort your table alphabetically by last name... If the names are in one field you are faced with a headache of having to first split the field, sort by the last name, then recombine. With proper design it's far simpler to first sort, then combine on the fly.
While design best practise obviously dictates having LastName and FirstName in separate fields, for the reasons stated, your example is probably the one case where it is actually easier to do with a single field of LastName FirstName. With a single field like this you simply sort on the one field. With two fields, you actually would have to do a double-sort, first on LastName and then on FirstName. There would be no practical reason to sort on LastName only; the records might be sorted alphabetically and they might not .

Linq ;0)>
Mar 15 '08 #8
mgstlucia
30 New Member
Thank You. I think I will go back to the combined field in the DB. It is a small database and only 54 records in the MEMBER table. Hopefully, it won't cause me any problems down the road.
Mar 16 '08 #9
Feroz37
2 New Member
Thanks all I solve the issues from your method
Mar 5 '17 #10

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

Similar topics

1
8753
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware tblSoftware ------------------- ------------------ ---------------------- PID PName PID* SID* SID SWName --- ----- --- --- --- ------ 1 Thomas 1 1 ...
0
1704
by: Sascha Folville | last post by:
Hi, I'm trying to transform a XML document to PDF using apache (xerces). I want different formatting for first and last page. My code looks like this: <fo:layout-master-set> <fo:simple-page-master master-name="first" ...> ... </fo:simple-page-master>
1
29291
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 with the ADSI NT Provider and only supported in the LDAP Provider. So given an UserId (UID) how can I read the First Name and Last Name using LDAP Provider. If anybody can help me with a C# sample code it would of great help. Thanks in advance.
5
47248
by: xixi | last post by:
hi, we are running db2 udb on v8.1, i am using jdbc sql, is there anyway to create a sql saying i want to get the last record of resultset? i try to open a big resultset and point the cursor to the last (like select * from table, then do resultset.last), i only want to get a one row back which is the last row of the resultset. thanks
20
5172
by: Tom Warren | last post by:
Is there a formal name for the (Mc,Mac,O,Van...) part of a last name? Tom
8
10323
by: Jean | last post by:
Hello all, I have the following data, that was queried and sorted to columns PROBLEM_ID and then by STATUSDATE (ascending): STATUS_ID STATUSDATE PROBLEM_ID --------- ---------- ---------- 10 12/04/2005 1234 40 15/05/2005 1234
32
4161
by: James Curran | last post by:
I'd like to make the following proposal for a new feature for the C# language. I have no connection with the C# team at Microsoft. I'm posting it here to gather input to refine it, in an "open Source" manner, and in an attempt to build a ground-swell of support to convince the folks at Microsoft to add it. Proposal: "first:" "last:" sections in a "foreach" block The problem: The foreach statement allows iterating over all the...
1
5073
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 with the ADSI NT Provider and only supported in the LDAP Provider. So given an UserId (UID) how can I read the First Name and Last Name using LDAP Provider. If anybody can help me with a C# sample code it would of great help. Thanks in advance.
1
5988
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 Data and I've got Last Name, First Name in the columns. I than have Table Full Name, with column Full Name. I have a relationship between the primary key of Table Data and the column Full Name. I have a form that displays the Full Name column. Its in...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10631
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10374
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.