Results 1 to 3 of 3
  1. #1
    svcghost is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    38

    Insert query into table FROM two table sources

    Hey guys.

    I'm trying to insert data FROM two tables into single records of a different table.

    So there are three tables: 1 destination, 2 sources

    I'm using the docmd.runsql vba function.. here's what I have:


    Code:
    DoCmd.RunSQL ("INSERT INTO SuiteEvents(Account, Section, Row, Seats, 
    NumSeats1, TypeSeat, Name, EventCode, EventDate, MaxSeats, MaxParking, Parking, Price) 
    SELECT AccountNumber, Section, Row, Seats, NumSeats1, TypeSeat FROM SuiteAccounts, 
    SELECT EventName, EventID, EventDate, SuiteMaxSeatCount, SuiteMaxParkingPass, 
    SuiteParkingPass, L_Price FROM EventPrep;")
    I know this code is wrong, but how can I use two SELECT statements as sources from different tables, to insert into a new destination table?

    Thanks guys!

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    you would use this format...

    INSERT INTO tablename (field1, field2, field3)
    SELECT table1.field1, table1.field2 table2.field3
    FROM table1, table2
    WHERE (something connecting the two tables)

  3. #3
    svcghost is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    38
    Thanks. I just used a left join instead of joining with the WHERE clause. Thanks man.

    Would give you REP but I gotta share the wealth first it appears.. hah

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

Similar Threads

  1. Insert into table
    By Mclaren in forum Programming
    Replies: 4
    Last Post: 05-02-2010, 11:28 PM
  2. Replies: 0
    Last Post: 02-24-2010, 12:56 AM
  3. Replies: 2
    Last Post: 10-27-2009, 07:09 AM
  4. Replies: 6
    Last Post: 08-17-2009, 01:41 AM
  5. Insert Query output into a table
    By ammu_sridhar in forum Programming
    Replies: 1
    Last Post: 06-12-2009, 01:09 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