How to copy data from one field to another field ?

  • Thread starter Thread starter Martin \(Martin Lee\)
  • Start date Start date
M

Martin \(Martin Lee\)

I have a field called [abc] in a table, with lots of data. Now, I want to
add another field called [abc1] in this table, and, to begin with this new
field, I need to copy all the existed data in [abc] into [abc1]. How to
make this?

Thanks!

Martin Lee
 
Hi Martin,

You simply need to use an Update query to update the values in your new
field with the values from your existing field. Create a new query. Dismiss
the Add Tables dialog without adding any tables. In query design view, click
on View > SQL View. You should see the word SELECT highlighted. Copy the
following SQL statement (Ctrl C) and paste it into the SQL view (Ctrl V),
replacing the SELECT keyword:

UPDATE [TableName] SET [TableName].[abc1] = [abc];


where you substitute "TableName" with the actual name of your table.

You can then switch back to the more familiar design view, if you wish, by
clicking on View > Design View. Run the query.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
UPDATE [TableName] SET [TableName].[abc1] = [abc];

if [abc] belongs to another table called [TableName2], how to do it ? I
tried ..... = [TableName2].[abc] but failed.

Martin Lee



Tom Wickerath said:
Hi Martin,

You simply need to use an Update query to update the values in your new
field with the values from your existing field. Create a new query.
Dismiss
the Add Tables dialog without adding any tables. In query design view,
click
on View > SQL View. You should see the word SELECT highlighted. Copy the
following SQL statement (Ctrl C) and paste it into the SQL view (Ctrl V),
replacing the SELECT keyword:

UPDATE [TableName] SET [TableName].[abc1] = [abc];


where you substitute "TableName" with the actual name of your table.

You can then switch back to the more familiar design view, if you wish, by
clicking on View > Design View. Run the query.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________


Martin (Martin Lee) said:
I have a field called [abc] in a table, with lots of data. Now, I want to
add another field called [abc1] in this table, and, to begin with this
new
field, I need to copy all the existed data in [abc] into [abc1]. How to
make this?

Thanks!

Martin Lee
 
Hi Martin,

For some reason, your last reply does not show up in the MS web portal, but I found it by using
the Outlook Express newsreader that I have previously configured:
http://www.microsoft.com/office/com...cess&mid=be8a3b19-a968-4874-bb12-2b374ca68c64

You need to have a field, or a combination of fields, that you can create a link between the
tables. For the purposes of this example, I simply added a numeric filed named "ID1" to the table
named "TableName", and a numeric field named "ID2" to the table named "TableName2". Then I added
values to the ID fields in both tables. Then use the following query:

UPDATE TableName2
INNER JOIN TableName ON TableName2.ID2 = TableName.ID1
SET TableName.abc1 = [TableName2].[abc];

Perhaps you already have some fields that can serve to join the two tables, so you won't need to
add these ID fields. You need to create the join, to pair up the records in each table, in order
to prevent a Cartesian product result.


Tom
_______________________________________________

in message
UPDATE [TableName] SET [TableName].[abc1] = [abc];

if [abc] belongs to another table called [TableName2], how to do it ? I
tried ..... = [TableName2].[abc] but failed.

Martin Lee

_______________________________________________

Hi Martin,

You simply need to use an Update query to update the values in your new
field with the values from your existing field. Create a new query.
Dismiss
the Add Tables dialog without adding any tables. In query design view,
click
on View > SQL View. You should see the word SELECT highlighted. Copy the
following SQL statement (Ctrl C) and paste it into the SQL view (Ctrl V),
replacing the SELECT keyword:

UPDATE [TableName] SET [TableName].[abc1] = [abc];


where you substitute "TableName" with the actual name of your table.

You can then switch back to the more familiar design view, if you wish, by
clicking on View > Design View. Run the query.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________


Martin (Martin Lee) said:
I have a field called [abc] in a table, with lots of data. Now, I want to
add another field called [abc1] in this table, and, to begin with this
new
field, I need to copy all the existed data in [abc] into [abc1]. How to
make this?

Thanks!

Martin Lee
 
Wouldn't you know it....as soon as I sent a reply using Outlook Express,
because I could not see your message using the web portal, it showed up just
fine. Go figure. Oh well.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

Tom Wickerath said:
Hi Martin,

For some reason, your last reply does not show up in the MS web portal,
but I found it by using the Outlook Express newsreader that I have previously
configured...

<snip>
 

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

Back
Top