Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    goalnightx is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    16

    Two left joins help

    Hello all,

    I'm stumped. Beginner Access user. I am joining two SUM queries to build a report but MS Access either duplicates the record or omits data when joining. Can you help me find what I am doing wrong?

    [code] SELECT Bkg_Sum.Expr1, Bkg_Sum.Expr2, Bkg_Sum.Expr3, Bkg_Sum.SumOfQbooked, Bkg_Sum.SumOfQconfirmd, Bkg_Sum.SumOfQrlsd, Inv_Sum.SumOfQonHand, Inv_Sum.SumOfQonHandNS, Inv_Sum.SumOfQinProgIC, Inv_Sum.SumOfQinProgOP, Inv_Sum.SumOfQinProgOther, Inv_Sum.SumOfQonHold, Inv_Sum.SumOfQavailable, Inv_Sum.SumOfQavailableNS, Inv_Sum.SumOfQavailOnSite, Inv_Sum.SumOfQavailOffSite
    FROM (PRODUCTS INNER JOIN Bkg_Sum ON PRODUCTS.KeyProduct = Bkg_Sum.Expr1) INNER JOIN Inv_Sum ON PRODUCTS.KeyProduct = Inv_Sum.Expr1
    WHERE (((Bkg_Sum.Expr1)=56)); [code]



    Results in records duplicating

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Depending on the join you could get duplicates.
    you could set the query to OUTER join (to get whats missing)
    and
    set it to UNIQUE VALUES = TRUE (to remove dupes)

  3. #3
    goalnightx is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    16
    Ranman,

    I tried that but still duplicating the records. Any other thoughts?

  4. #4
    goalnightx is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    16
    Here is the query and records produced. The red lines indicate the duplicate records.Click image for larger version. 

Name:	Access_Dups.JPG 
Views:	13 
Size:	56.2 KB 
ID:	27676
    Click image for larger version. 

Name:	Access_Dups1.JPG 
Views:	13 
Size:	99.4 KB 
ID:	27677

  5. #5
    goalnightx is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    16
    Anyone with some thoughts on this? just trying to get this solved as soon as possible. Thanks in advance. G

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Could you post your database, or this portion of it?

  7. #7
    goalnightx is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    16
    Yes. Let me slim it down to fit the forum criteria. Just a minute. Thx

  8. #8
    goalnightx is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    16

    Zipped

    archive.zip

    Had to compress it. Here ya go. Thanks!

  9. #9
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You need something else to join on, KeyProduct is not enough, that is why it is showing all records from each query (2 + 2). Still looking!

  10. #10
    goalnightx is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    16
    There ia also a productcode as well but when I did that it didnt seem to work. BTW I appreciate you looking at this. G

  11. #11
    goalnightx is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    16
    Click image for larger version. 

Name:	Inv_Sum.JPG 
Views:	10 
Size:	32.5 KB 
ID:	27685

    Click image for larger version. 

Name:	Bkg_Sum.JPG 
Views:	10 
Size:	19.9 KB 
ID:	27686


    The result is this when I try to join the Expr2 and Expr3 fields. It needs to show the MN with the associated data in the second image.

    Click image for larger version. 

Name:	Pos_Qry.JPG 
Views:	10 
Size:	30.5 KB 
ID:	27687

  12. #12
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    There is an "expr3" on Bkg_sum and an "expr2" on Inv_sum - are these two the same data? If you get the original table where these come from and do left joins you would end up with three records - is that what you are expecting?

  13. #13
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    (posts crossed)

  14. #14
    goalnightx is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    16
    Yes, correct. My hope then is is would tell me in Region MN that i have zero Qty On Hand and that I need some of the 550 in Region WI to transfer to MN as that is where the demand for the product is.

  15. #15
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Bring in the table to Pos_Qry - it wasn't in the database that you posted. Remove Products, you don't need that

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

Similar Threads

  1. Replies: 16
    Last Post: 06-06-2016, 08:45 AM
  2. Multiple Left Joins From Same Column
    By x0200196 in forum Access
    Replies: 1
    Last Post: 09-08-2011, 10:14 AM
  3. LEFT/RIGHT/OUTER JOINS in a set of subqueries
    By luckycharms in forum Queries
    Replies: 1
    Last Post: 08-01-2011, 05:06 PM
  4. Help With Left Joins
    By DaveyJ in forum Queries
    Replies: 23
    Last Post: 06-28-2010, 08:38 AM
  5. Examples of left joins?
    By narayanis in forum Queries
    Replies: 0
    Last Post: 06-14-2008, 06:17 AM

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