Solved

How to combine multiple tables in Access 2010 into single table

Posted on 2014-09-03
7
7,685 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
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HasData 9 35
MS Access to SQL Conversion - Bit and Yes/No Datatypes 12 44
Problem with syntax with TransferDatabase 3 13
Extract string portion 2 0
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now