How do I join the data from 2 columns in the same table?

W

whassichic

hello all,

i created a table with ID, grade, student last name, first name.
it's a table with over 1,700 records. now after doing all this work, i
realize that i should have put the info on first and last name in the same
column.

any step-by-steo instruction on how to join these 2 columns (last and first
names) into ONE column would be greatly appreciated.

thanks
 
V

Van T. Dinh

It is _correct_ to store LastName and FirstName as 2 separate Fields. This
way, you can easily sorted by LastName or FirstName depending on the
situations.

If you want to combine the names, you can easily do this in a Query. In the
Query Grid, enter in the Field row of an empty Column:

FullName: [LastName] & ", " & [FirstName]

When you run the Query, the FullName will be displayed.
 
A

axeman422

If you want a column with the full name of your students add a new column
call it fullname (as an example)
then create a new form in design mode put in a command button and change
properties of on click to even procedure then click the ... next to it and
add this in the vba

Private Sub cmdsetname_Click()
DoCmd.RunSQL "update Table1 set [fullname] = [firstname] & ' ' &
[lastname]"
End Sub

Table1 is the name of the table where your names are
fullname is the new column name
firstname is the column with the students first name
lastname is the column with the students last name
the ' ' & just adds a space between the 2 names
now go to your new form and in form view click on the button a little popup
will appear saying you are about to update 1700 rows or how ever many
students you have click yes and now you have a column with both first and
last name in it

=) have fun
 
A

axeman422

DoCmd.RunSQL "update Table1 set [fullname] = [lastname] & ' ' & [firstname]"

or this if you want last name to be before first name
that's all on 1 line too by the way I noticed the forum cropped it to
continue on next line
 
W

whassichic

Hello guys,

First of all, THANK U so very much for replying with wonderful instructions,
it was very helpful. I really can't thank you enough. However, immediately
after my 'panic attack' :) when i realised the mistake i made, i had to
attend a meeting and a friend of mine sat up and cut-n-paste each first name
to the corresponding last name. But trust me the info you shared with me will
not go to waste.

thanks again,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top