Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    cfobare79 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    66

    Merge Tables


    It there a way to merge information from one table into another? I thought creating a relationship would make this connection.

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    You could use a Union All Query.

    Select * from Table1
    Union All
    Select * from Table2

    Both tables need the same number of fields.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Creating a relationship in the relationship window will not make this happen. Perhaps a query will suffice. You can create a query using the Query Designer. While there, create a JOIN. This will cause the query to retrieve data that is relevant from two or more tables.

    And yes, it is possible to merge two tables into one. The end result would be one table.

  4. #4
    cfobare79 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    66
    Is there a way to merge data from one table into another. I believe the queries above would create a new table.

  5. #5
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    You could make an append query to append all data from one table into the other.

    Queries do not make a new table.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Can do an INSERT SELECT sql action to copy records from one table to another or do copy/paste.

    Why do you need to do this? Is this a one-time event?

    What exactly are you trying to do? Do you want to UNION or JOIN datasets?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    cfobare79 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    66
    This issue I am dealing with is I receive an Excel sheet with billing information. The Excel only has the AgencyName and other billing infomation. All my Reports are ran using an AgancyID. I was thinking if I imported the Excel sheet into a table which had a column for AgancyID that the AgancyTable would be able to identify the AgencyName and add the AgencyID. Any suggestions would be wonderful.

  8. #8
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    If you can do this by hand without editing large amounts of data, you should be able to make it happen 'automagically' Your thoughts sound correct.

    I would make a query which prepares the data that you imported from excel. In this query you would resolve what AgencyName should be based off the Agencies table.

    then have that data appended to the 2nd table.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    This all depends on confidence that the names are always spelled correctly in the Excel file. Any variation in name and record will not match to the ID.

    How complex is the Excel sheet structure? Can you set a link to it?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    cfobare79 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    66
    Sorry, I can't let you see the sheet because of the information on it. I'm very confident the names will be correct since it is computer generated. basicly what I want to do is a DLookup function within access.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Computer generated or not, someone somewhere sometime entered data into a database. Names are often unreliable key identifiers.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    cfobare79 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    66
    I think that append query should work but I can't get it to function properly. Click image for larger version. 

Name:	Capture.PNG 
Views:	10 
Size:	3.7 KB 
ID:	20558 This is the query I'm running. I know this sounds backward from what I was asking but it's because this is test data and has AgencyID but not AgencyName in the 'David" file.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    First you need to do a query that joins AgencyList to the imported (or linked) Excel records then use that dataset as source for the INSERT. An all-in-one SQL statement would be like:

    INSERT INTO datatablename(AgencyID, {other fields as needed}) SELECT AgencyID, {other fields as needed} FROM AgencyList INNER JOIN ExcelImport ON AgencyList.AgencyName = ExcelImport.AgencyName
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    cfobare79 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    66
    I was going to import the excel prior to doing the query. I'm sure the query would be similar but it sounds like you are telling me I cant do an Append Query.

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    That is an append query.

    What table do you want these new records appended to?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need to Merge 6 Similar Tables
    By CJS in forum Queries
    Replies: 6
    Last Post: 04-21-2015, 10:14 AM
  2. how to merge two or more tables horizontally with vba?
    By registoni in forum Programming
    Replies: 2
    Last Post: 09-20-2013, 06:43 AM
  3. Don't know if I should merge tables (please help)
    By bigdaddy757 in forum Database Design
    Replies: 2
    Last Post: 05-30-2013, 01:52 PM
  4. Merge linked tables!
    By thaonguyen1013 in forum Access
    Replies: 14
    Last Post: 02-01-2012, 04:03 PM
  5. How do I Merge Four Tables Together
    By SteveI in forum Queries
    Replies: 1
    Last Post: 03-04-2010, 10:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums