Results 1 to 4 of 4
  1. #1
    jcarstens is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    6

    Comparing two tables


    I am having a tuff time figuring this out and I am sure it is super simple. I have a table which list sales and one which lists returns. These are related by a common order number. I would like to see a query of all order numbers, but only the items which have been returned.

    My problem is it is replicating the returned line for every line of the original order number. I am attaching a sample database which depicts which I am trying to do. Query 1 shows the data in the wrong format. The screenshot below shows how I would like the output (with the struck out records to be blank)

    Click image for larger version. 

Name:	screen.jpg 
Views:	10 
Size:	48.5 KB 
ID:	7500

    Any help with this would be greatly appreciated.
    Attached Files Attached Files
    Last edited by jcarstens; 05-09-2012 at 08:00 PM. Reason: Solved

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,621
    Need to do a compound join. Like:

    SELECT tblSales.OrderNumber, tblSales.OrderDate, tblSales.Item, tblReturns.ReturnedDate, tblReturns.Item
    FROM tblReturns LEFT JOIN tblSales ON (tblReturns.Item = tblSales.Item) AND (tblReturns.[Original Order Num] = tblSales.OrderNumber);
    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
    jcarstens is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    6
    I have tried that code but that leaves my query with just the two records. I want to see all items purchased but only the returned item in the query. Referring back to my original screenshot, I want the same number (5) records with just the applicable returns showed.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,621
    Then reverse the join:

    SELECT tblSales.OrderNumber, tblSales.OrderDate, tblSales.Item, tblReturns.ReturnedDate, tblReturns.Item
    FROM tblReturns RIGHT JOIN tblSales ON (tblReturns.Item = tblSales.Item) AND (tblReturns.[Original Order Num] = tblSales.OrderNumber);
    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.

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

Similar Threads

  1. Comparing two tables.
    By elmister in forum Access
    Replies: 11
    Last Post: 08-24-2011, 11:59 AM
  2. Comparing two tables.
    By elmister in forum Queries
    Replies: 1
    Last Post: 08-22-2011, 05:32 PM
  3. Comparing Records in two (2) Tables.
    By RalphJ in forum Programming
    Replies: 19
    Last Post: 04-19-2011, 02:50 AM
  4. Comparing tables
    By YoungWolf in forum Database Design
    Replies: 7
    Last Post: 01-10-2011, 11:32 AM
  5. Comparing two tables with query
    By Dnphm in forum Queries
    Replies: 2
    Last Post: 08-13-2010, 02:45 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