473,320 Members | 1,922 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.

Concatenate First Name and Last Name fields into Full Name field

Zubair Mughal
3 2Bits
I have 3 fields in my Staff database.
First Name;
Last Name;
Full Name.

I want to Concatenate First Name and Last Name fields to STORE/SAVE in Full Name fields at frmStaff on tblStaff.
Sep 15 '20 #1
6 3476
Nauticalgent
100 64KB
Hello there!

Easy to do, but I would suggest NEVER storing concatenated data. It is a better practice to do this for Forms, Reports, and Queries - but not in a table. What if the name changes, or if you make a mistake and have to change it?

Anyway, to answer your question:

[First Name] & " " & [Last Name]

- or -

[Last Name] & ", " & [First Name]

Again, I strongly urge you to not do this at the table level...
Sep 15 '20 #2
twinnyfo
3,653 Expert Mod 2GB
Zubair,

Welcome to Bytes!

I will echo what Nauticalgent suggests and refrain from having this as a field within a Table. There is really no reason/need to have a field with this concatenated Full Name. If you ever need to display the full name, just concatenate it at run time--either within your Query, Form or Report. This has to do with basic, good DB design of avoiding the duplication of data. For small datasets, this doesn't matter in the overall scheme of things, but at Bytes, we prefer to guide you down the "right" path, and not just a path that will solve your temporary problem while creating others.

Hope this hepps!
Sep 15 '20 #3
Zubair Mughal
3 2Bits
I much appreciated for your Right Path to do concatenate Full Name at Table level.Thanking you.
Sep 16 '20 #4
NeoPa
32,556 Expert Mod 16PB
I'm not sure if you're misunderstanding or mis-expressing what the others have said.

DON'T store the concatenated field in a table! Create it as and when you need it from the basic data that is already available from [First Name] & [Last Name].

This is very easy to do in a Query for instance as :
Expand|Select|Wrap|Line Numbers
  1. SELECT [First Name]
  2.      , [Last Name]
  3.      , [Last Name] & (', '+[First Name]) AS [FullName]
  4. FROM   [tblStaff]
Notice the use of the + character for string concatenation with Null propagation. Also notice the use of the correct SQL standard quotes (') for when working in SQL as opposed to the double-quotes (") as used in VBA. Jet/ACE is very forgiving and supports both, but that can leave you with complications down the line if you rely on that.
Sep 17 '20 #5
AjayGohil
83 64KB
No point of doing this. You can get Full-Name using Firstname and Lastname whenever you need. You don't nedd to store full name in database.If you ever change Firstname or Lastname then Fullname become outdated. when you need to display Full Name, just concate the two of them. Do not Repeat Data in your Database.

"select concat(firstname,' ',lastname) as name from users";
Sep 23 '20 #6
twinnyfo
3,653 Expert Mod 2GB
Ajay,

Yes, you have restated what others have already stated, but you also included a Concat() function that does not exist natively in Access (it does exist in mySQL and SQL server). If you would like to post your version of code to declare such a function in MS Access VBA, that is certainly welcome here, as this would be a useful function--or you can create a new thread/article describing this User-Defined function.

Thanks!
Sep 23 '20 #7

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

Similar topics

4
by: John | last post by:
Good Day all I have a single field that has both the first and last names in it. In some records we even have a middle initial. I was thinking of using the Left (Fullname,XX) function to get the...
2
by: billy001 | last post by:
How do I go about grabbing only the last name out of a 'Full Name' field ? I've so far tried executing a parse script in Oracle 9i using SQL Plus and am not successfully getting any data returned. ...
0
by: Trevor2007 | last post by:
I am trying to retrieve the windows account holders first and last name for the that is currently logged in, I would like to do it with WMI since object.get doesn't work very well with VBA. (Need to...
2
dlite922
by: dlite922 | last post by:
I'm reading a CSV file and the firstname and last name are together separated by a space. (There could be middle name or middle initial as well, but is being ignored) Since i'll be doing this...
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...
3
by: Mo Ewing | last post by:
I have a field in my database with people's names. Each field has only one first name but may have more than one last name. The first name is always the first word in the field. I would like to...
1
by: hexyz hexagonal | last post by:
This is the code I have for the person.java file // Person.java // Creates and manipulates a person with a first name, last name and age public class Person { private String...
2
by: nikkicorrea | last post by:
how to enter person's last name and first name seperated by space and comma. for example henry smith---output-->>smith,henry
2
by: hh22 | last post by:
I want to join a patient id from a table to a first name and last name in another table, how can i do that?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.