I want to Concatenate First Name and Last Name fields into Full Name Field

Zubair Mughal

New member
Local time
Today, 16:07
Joined
Sep 10, 2020
Messages
3
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.
 
Add code to the Form's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as integer)
[Full Name] = [First Name] & (" " + [Last Name])
End sub

[Full Name] must be added to the form.
 
Hi. Welcome to AWF!

Also, you could consider using a Calculated Column.
 
As I posted on Bytes:

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...

I would add that Arnel's code is much cleaner if you choose to store this data - which you shouldn't - but since I don't beat dead horses...
 
As I posted on Bytes:



I would add that Arnel's code is much cleaner if you choose to store this data - which you shouldn't - but since I don't beat dead horses...
Just as FYI... Calculated Columns are available in Access and in SQL Server (and SharePoint). When you update any of the fields involved in the calculation, the calculated column is automatically updated also (no out of sync situation and you don't have to remember to do anything). :)
 
Just as FYI... Calculated Columns are available in Access and in SQL Server (and SharePoint). When you update any of the fields involved in the calculation, the calculated column is automatically updated also (no out of sync situation and you don't have to remember to do anything). :)
I see...good to know! I just have always stayed away from them because those much smarter than me (not hard to make that list!) have always said "that way lies madness". I but them in the same category as Multi-Valued Fields.

So...

In your opinion and experience, are calculated fields victim of bad-press and unfounded allegations?
 
I see...good to know! I just have always stayed away from them because those much smarter than me (not hard to make that list!) have always said "that way lies madness". I but them in the same category as Multi-Valued Fields.

So...

In your opinion and experience, are calculated fields victim of bad-press and unfounded allegations?
Hi. Obviously, no system is perfect. But, if something is available in Access, but not available in SQL Server, e.g. Attachment Fields, MVFs, then I would avoid them too. However, since Calculated Columns are available to both, I don't see any harm in using them in Access or SQL Server. Still, it's just an option. No one is saying you "have to" use them.
 
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.
3 fields were given
> no worries
> would be: [Full Name]=[Last Name] & ", "& [First Name]
> on [Last Name] and [First Name] update insert code above
 
Add code to the Form's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as integer)
[Full Name] = [First Name] & (" " + [Last Name])
End sub

[Full Name] must be added to the form.

That’s the perfect as I required. Thanks a lot.
 

Users who are viewing this thread

Back
Top Bottom