Solved

How to combine multiple tables in Access 2010 into single table

Posted on 2014-09-03
7
10,372 Views
Last Modified: 2014-09-12
Hello,

I have 7 tables of information, all tables have the same fields.  I would like to combine the tables into 1 master table and then remove the previous ones.  My intent to do this is so I then have just one table to work with in trying to isolate and remove duplication.  Any and all assistance would be greatly appreciated.
0
Comment
Question by:FreddyBass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 37

Expert Comment

by:Neil Russell
ID: 40301936
INSERT INTO maintablename SELECT * FROM firstoldtable
INSERT INTO maintablename SELECT * FROM secondoldtable
INSERT INTO maintablename SELECT * FROM nextoldtable

etc...
0
 

Author Comment

by:FreddyBass
ID: 40301982
Hi Neilsr,

Thank you for your input, where to put what you have written?

INSERT INTO maintablename SELECT * FROM firstoldtable
INSERT INTO maintablename SELECT * FROM secondoldtable
INSERT INTO maintablename SELECT * FROM nextoldtable
0
 
LVL 37

Accepted Solution

by:
Neil Russell earned 500 total points
ID: 40301990
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 30

Expert Comment

by:hnasr
ID: 40302004
Try:

SELECT * INTO mainTable
FROM (SELECT * FROM tbl1 UNION  SELECT * FROM tbl2 ...  UNION SELECT * FROM tbl7)

... to be replaced by UNION for all other remaining tables
0
 

Author Comment

by:FreddyBass
ID: 40302013
Hello Neilsr,

I will have a look at the following link and let you know if that provides the solution I am looking for.

Thank you

Fred
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 40303643
It might be better to do this operation in VBA code.  If each table has an ID field as the key field, you won't be able to append to that field.  Also, you may need to check for duplicates before adding a record.  In some cases it might be more appropriate to update an existing record rather than adding a new one.  here is some typical code for an "append or update" choice:
      strSearch = "[Code] = " & lngCode
      Debug.Print "Search string: " & strSearch
      rstTarget.FindFirst strSearch
      
      If rstTarget.NoMatch = True Then
         'Add new record
         rstTarget.AddNew
         rstTarget![Code] = lngCode
         rstTarget![TechName] = strTech
         rstTarget![WorkDate] = dteWork
         rstTarget![StartTime1] = rstSource![StartTime]
         rstTarget![EndTime1] = rstSource![EndTime]
         curRate = CCur(Nz(rstSource![Rate]))
         rstTarget![Rate] = curRate
         rstTarget.Update
      Else
         'Update existing record
         rstTarget.Edit
         rstTarget![StartTime2] = rstSource![StartTime]
         rstTarget![EndTime2] = rstSource![EndTime]
         rstTarget.Update
      End If

Open in new window

0
 

Author Closing Comment

by:FreddyBass
ID: 40319945
Thank you for providing me the link, I was able to find more information there for what I am trying to do
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question