Importing data from one table to another

T

Tony Williams

I have two tables tblmain and tblturnover. The second table tblturnover
includes data for a number of companies for different dates and I want to
import the data from tblturnover to tblmain for each compnay. I have tried
using an append query but it just adds the data as additional data rather
than adding it to the existing compnay records in tblmain.
To illusttrate:

tblmain
txtcompany............txtdate............data1...............data2.........data3.............etc

tblturnover
txtcompany............txtdate............data1...............data2.........data3.............etc

I want to add the values of data1, data2, data3 etc from tblturnover to the
fields data1, data2, data3 etc in tblmain where tblmain.txtcompany and
tblmain.txtdate equal tblturnover.txtcompanyand tblturnover.txtdate

Anyone help?
Thanks
Tony
 
G

Guest

When you say "add to", do you mean this is numeric data you want add or text
data you want to concatenate?
 
T

Tony Williams

Sorry for being vague. The fields in tblmain have no data I want to fill
them with the data that is in tblturnover. It is numeric data
Thanks
Tony
 
G

Guest

All you need is an Update query. In the query builder select the fields you
want to update to and from, and select the company and date in the tables to
match in the criteria row.
 
T

Tony Williams

Hi I'm not sure I understand. Could you elaborate because I can't see how I
can put in the second table name in the Update query.
What I want is to update tblmain.Data1 with the value of tblturnover.data1,
update tblmain.Data2 with the value of tblturnover.data2, update
tblmain.Data3 with the value of tblturnover.data3 etc
How do I do that?
Thanks
Tony
 
G

Guest

Create a New query
Select tblMain
Select tblturnover
Create A Join from tblMain.Company to tblturnover.Company
Create A Join from tblMain.txtdate to tblturnover.txtdate

In your field row Select
tblMain.Data1
tblMain.Data3
tblMain.Data3

In your Update To row
for Column tblMain.Data1
Enter [tblturnover]![data1]
for Column tblMain.Data2
Enter [tblturnover]![data2]
for Column tblMain.Data3
Enter [tblturnover]![data3]

Now when you run the query, it will update the data in each of the data
fields in tblMain to whatever is in each of the data fields in tblturnover

Be sure you make a backup before you do this, then check the results.
 
T

Tony Williams

Thanks that worked fine!
Tony
Klatuu said:
Create a New query
Select tblMain
Select tblturnover
Create A Join from tblMain.Company to tblturnover.Company
Create A Join from tblMain.txtdate to tblturnover.txtdate

In your field row Select
tblMain.Data1
tblMain.Data3
tblMain.Data3

In your Update To row
for Column tblMain.Data1
Enter [tblturnover]![data1]
for Column tblMain.Data2
Enter [tblturnover]![data2]
for Column tblMain.Data3
Enter [tblturnover]![data3]

Now when you run the query, it will update the data in each of the data
fields in tblMain to whatever is in each of the data fields in tblturnover

Be sure you make a backup before you do this, then check the results.

Tony Williams said:
Hi I'm not sure I understand. Could you elaborate because I can't see how
I
can put in the second table name in the Update query.
What I want is to update tblmain.Data1 with the value of
tblturnover.data1,
update tblmain.Data2 with the value of tblturnover.data2, update
tblmain.Data3 with the value of tblturnover.data3 etc
How do I do that?
Thanks
Tony
 

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