Results 1 to 2 of 2
  1. #1
    gutenberg is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2016
    Posts
    31

    Creating a Join Query

    I am trying to create a join query that will combine 3 different queries called Q_OrderDelAlt, Q_OrderDtl, and Q_OrderHdr.

    The 3 different tables I want to use are called: OrderDetail, OrderHeader and OrderDeliveryAlt.

    Each table has the same field called OrderNu

    Here is the SQL for the join query:

    SELECT OrderDetail.OrderNu,
    FROM OrderDetail
    WHERE (((OrderDetail.OrderNu)=[Enter the OrderNu:]))
    ORDER BY OrderDetail.OrderNu
    Union
    SELECT OrderHeader.OrderNu,
    FROM OrderHeader
    WHERE (((OrderHeader.OrderNu)=[Enter the OrderNu:]))
    ORDER BY OrderHeader.OrderNu


    UNION SELECT OrderDeliveryAlt.OrderNu,
    FROM OrderDeliveryAlt
    WHERE (((OrderDeliveryAlt.OrderNu)=[Enter the OrderNu:]))
    ORDER BY OrderDeliveryAlt.OrderNu;

    I get this error message when I run the Join query:

    Click image for larger version. 

Name:	Join Query - Error Message.jpg 
Views:	8 
Size:	23.9 KB 
ID:	29115

    Does anybody know how to make this join query work properly?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    The commas at the end of the SELECT clauses will cause an error. You only want the last ORDER BY.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 7
    Last Post: 03-23-2017, 10:26 AM
  2. Join Query?
    By KWarzala in forum Forms
    Replies: 5
    Last Post: 07-29-2014, 02:44 PM
  3. Replies: 6
    Last Post: 11-19-2013, 01:38 AM
  4. Join Query
    By hithere in forum Queries
    Replies: 4
    Last Post: 02-17-2012, 06:18 AM
  5. Help creating outer join query
    By jobrien4 in forum Queries
    Replies: 5
    Last Post: 09-12-2011, 01:56 PM

Tags for this Thread

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