Results 1 to 11 of 11
  1. #1
    Jerseynjphillypa is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2012
    Posts
    83

    Combined Tables

    What is the easiest way to combine 5 tables (table 1, table2, table 3 ...) that are linked into access from Excel into one table in access.



    All 5 tables have the following fields
    DateEnter (Date/Time)
    Location (text)
    First Name (text)
    Last Name (text)
    Used (Number)
    Total (Number)

    Code:
    INSERT INTO [ALLTABLE] ([DATEENTER],[LOCATION],[FIRST NAME], [LAST NAME],[USED],[TOTAL])SELECT [TABLE 1].[DATEENTER],[TABLE 1].[LOCATION],[TABLE 1].[FIRST NAME],[TABLE 1].[LAST NAME],[TABLE 1].[USED],[TABLE 1].[TOTAL],
    [TABLE 2].[DATEENTER],[TABLE 2].[LOCATION],[TABLE 2].[FIRST NAME],[TABLE 2].[LAST NAME],[TABLE 2].[USED],[TABLE 2].[TOTAL]
    FROM [TABLE 1], [TABLE 2]
    WHERE ((([TABLE 1].[LOCATION])="NJ") AND (([TABLE 2].[LOCATION])="NJ"));
    I get the error (Duplicate output destination 'DateEnter'

    How would I use a Union Query if I am not appending the data. I just want to make the table each time I run the macro in Access

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Hasn't this already been resolved in https://www.accessforums.net/showthr...ith-Date-Query
    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.

  3. #3
    Jerseynjphillypa is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2012
    Posts
    83
    Yes it's similar but I didn't know how to remove the DateEnter part since the information is already populated in the tables. I am also not appending the information from one table to another table.

    I just want all the tables now to go into the same Data Table without doing the appending to another data table.

    So would I do something like
    Code:
    INSERT INTO QueryTable
    Select [Item],[Location],[Supplier]
    FROM [Information]
    UNION Select [Item],[Location],[Supplier]
    From [Information 2];
    I get a syntax error in from clause

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Follow the same syntax as shown in the other thread:

    INSERT INTO QueryTable(Item, Location, Supplier) SELECT InfoUnion.*
    FROM (SELECT Item, Location, Supplier FROM Information
    UNION SELECT Item, Location, Supplier FROM [Information 2]) As InfoUnion;
    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.

  5. #5
    Jerseynjphillypa is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2012
    Posts
    83
    I get getting the error "Number of query values and destination fields are not the same"

    I created the table QueryTable with the field Item, Location Supplier

    I couldn't save the query since I had the error
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Looks like wildcard is not a good idea. Try:

    INSERT INTO QueryTable(Item, Location, Supplier) SELECT Item, Location, Supplier
    FROM (SELECT Item, Location, Supplier FROM Information
    UNION SELECT Item, Location, Supplier FROM [Information 2]) As InfoUnion;
    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
    Jerseynjphillypa is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2012
    Posts
    83
    Thanks for the help

    Instead of a append table, is there a way it can me a make table?

    Since i don't want the data to keep appending to the table

    So the make table destroy the Querytable and create a new table every time I run the Query

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Run DELETE query to remove all records then run the INSERT for the new records. The following will delete all records in the table: DELETE FROM QueryTable;
    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.

  9. #9
    Jerseynjphillypa is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2012
    Posts
    83
    thanks for all the help..

    Also If I want to change the Field Header can I do the following
    INSERT INTO QueryTable(Item, Place, Supplier) SELECT Item, Location, Supplier
    FROM (SELECT Item, Location AS Place, Supplier FROM Information
    UNION SELECT Item, Location AS Place, Supplier FROM [Information 2]) As InfoUnion;

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    No, can only insert data into a field that is actually already in the table. If you want the name to be Place then edit the design of the table and also adjust the query.
    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.

  11. #11
    Jerseynjphillypa is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2012
    Posts
    83
    thanks for your help June7

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Working on an SQL Insert / Update combined
    By robsworld78 in forum Programming
    Replies: 0
    Last Post: 02-23-2012, 10:24 PM
  2. Replies: 1
    Last Post: 12-04-2011, 01:19 PM
  3. 2 Fields combined to textbox not working
    By kris335 in forum Forms
    Replies: 3
    Last Post: 09-19-2011, 10:32 AM
  4. Combined Reports
    By baum12 in forum Reports
    Replies: 1
    Last Post: 05-05-2011, 03:19 AM
  5. Combined Fields as Memo
    By Duval in forum Queries
    Replies: 11
    Last Post: 09-13-2010, 08:56 PM

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