Results 1 to 10 of 10
  1. #1
    kwooten is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    255

    query to produce table where ID may be in one table but not the other


    I am trying to create a table based on a projects actual expense and budget. The budget for each project is given a 4 digit code and the report we use for actual expense also tells us the same 4 digit code. So getting a query to produce a table for actual spend vs budget is easy based on where the 4 digit codes are equal; however I also need the query to produce results for where there is budget but no actual expense as well as actual expense but no budget. How do I get a query to output all the information into one table?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why would a project not have a budget?

    You need a dataset of all possible projects.

    Do aggregate query for the expenses.

    Join the query and the budget table to the projects dataset.
    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
    kwooten is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    255
    project could have closed early so we could run a deficit until the budgeted close date.

    I have thought about that but it doesn't solve the problem of having budget but 0 expense.. Projects get delayed so we could run surplus budget for a couple months. I seem to be able to make it where I can show budget for all the expense that has posted or all of the budget even if there is no expense but nothing that shows both.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    All projects will show if you use an ALL PROJECTS dataset. Then join the other datasets to that one but don't use INNER JOIN.
    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.

  5. #5
    kwooten is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    255
    that is part of the problem.. I don't have an "All Projects" dataset.. I have to use the actual expense file (which could/will change each month as new project start taking expense) and the budget file. Is there a way to create an "All Projects" dataset based on these two tables?

  6. #6
    kwooten is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    255
    think I got it to work.. it isn't exactly pretty but basically I took the actual expense file and created a table of the project ID's then took the budget file and appended the project ID's (excluding duplicates) from that table into the table created from the actual expense.. this gave me a list of all the ID's then I used the actual tables and joined them to my new "All projects" list to get the other information I needed... Is this what you would have done?

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Only if you intend to maintain that table. It does make sense to have Projects table with general info about project.

    However, could have done a UNION query to generate the dataset of all project numbers.
    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.

  8. #8
    kwooten is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    255
    I have never done a UNION query before.. if that would eliminate the need to maintain the table then that would be preferable.. How do those work?

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Search web. Here is a start http://www.w3schools.com/SQl/sql_union.asp
    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.

  10. #10
    kwooten is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    255
    yeah the UNION is much easier..

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

Similar Threads

  1. Replies: 10
    Last Post: 03-05-2015, 07:33 PM
  2. Query to produce Items to Action Table
    By Chris Waller in forum Queries
    Replies: 4
    Last Post: 10-16-2014, 09:54 AM
  3. Replies: 2
    Last Post: 01-28-2013, 11:32 AM
  4. Replies: 17
    Last Post: 09-24-2012, 08:42 AM
  5. Replies: 2
    Last Post: 10-27-2009, 07: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