Results 1 to 8 of 8
  1. #1
    Crdmster is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    13

    Question Combining Queries - DB Issue

    Hey yall, I'm running into this issue quite often so any advice is appreciated. There could be an easy solution, but I havn't found it yet.

    I have two queries:
    1) Query 1 contains the project ID, task ID, & budget.
    2) Query 2 contains the project ID, task ID, & the total consumed hours.

    I want to combine these two queries (soon to be Query 3) in order to determine the remaining hours per task ([budget] - [consumed hours]).

    The issue:
    1) If Query 2 does not contain a value for total consumed hours then Query 3 will not list all of the budgeted hours.



    ~I've attached a pdf showing what I want Query 3 to look like, as well as what Queries 1 & 2 look like.


    MS Access Query Issue.pdf

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I cannot download your file, but you should be able to use the NZ function to return a zero in the case of missing data, i.e.
    Code:
    =Nz([total consumed hours],0)+0

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You need to edit the joins between the queries. Right or double click on each and the appropriate choice should be obvious.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Crdmster is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    13
    Hey Joe, thanks for the quick response! Just to test it out, I've added the Nz() function around ALL of the variables in the SQL statement and my end results is still only 3 rows.

    Should I upload the attachment is a different format for viewing (seeing the image helps to illustrate the issue)? I made it a pdf in hopes that it would be easier to view.

  5. #5
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Hey Joe, thanks for the quick response! Just to test it out, I've added the Nz() function around ALL of the variables in the SQL statement and my end results is still only 3 rows.
    See Paul's comments above. You do not want to use an INNER JOIN in this case, as that only returns the matches. You want an Left Outer Join from Query1 to Query2. You use the Nz in conjunction with that.

  6. #6
    Crdmster is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2017
    Posts
    13
    Quote Originally Posted by JoeM View Post
    ... You do not want to use an INNER JOIN in this case, as that only returns the matches. You want an Left Outer Join from Query1 to Query2. ...
    Thanks Paul & Joe, that last statement you made is what I was missing. Thanks alot!!!

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problemo.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are welcome.

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

Similar Threads

  1. Combining two queries
    By joeshig in forum Queries
    Replies: 4
    Last Post: 01-30-2017, 09:02 AM
  2. Combining Queries?
    By Khermann in forum Queries
    Replies: 1
    Last Post: 06-02-2016, 08:34 AM
  3. Replies: 9
    Last Post: 08-27-2014, 11:34 AM
  4. combining 2 queries
    By sdel_nevo in forum Queries
    Replies: 2
    Last Post: 07-23-2014, 04:41 AM
  5. Combining queries
    By jamo in forum Queries
    Replies: 11
    Last Post: 11-09-2012, 07:36 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