Results 1 to 3 of 3
  1. #1
    m0aje is offline Novice
    Windows XP Access 2000
    Join Date
    Nov 2012
    Posts
    10

    Unhappy Combining a two union queries and creating a report on those results

    I am using the following UNION QUERY to total up equipment tested for a report.




    SELECT "Laptops Tested" AS PCEQUIP, Count(*) AS RECORDS
    FROM [LAPTOPS]
    WHERE (((Date)Between [Enter Start Date] AND [Enter End Date]));
    UNION
    SELECT "Workstations Tested" AS PCEQUIP, Count(*) AS RECORDS
    FROM [WORKSTATION]
    WHERE (((Date)Between [Enter Start Date] AND [Enter End Date]));
    UNION
    SELECT "Printers Tested" AS PCEQUIP, Count(*) AS RECORDS
    FROM [PRINTER]
    WHERE (((Date)Between [Enter Start Date] AND [Enter End Date]));
    UNION
    SELECT "Servers Tested" AS PCEQUIP, Count(*) AS RECORDS
    FROM [SERVER]
    WHERE (((Date)Between [Enter Start Date] AND [Enter End Date]));


    UNION QUERY RESULTS:

    Start Date 6/1/14 End Date 6/18/14



    Laptops Tested 27
    Workstations Tested 18
    Printers Tested 22
    Servers Tested 19

    Works beautifully!



    I created this query to actually tally up the equipment in the above query.


    SELECT SUM(Records)
    FROM
    (
    SELECT "Laptops Tested" AS PCEQUIP, Count(*) AS RECORDS
    FROM [LAPTOPS]
    WHERE (((Date)Between [Enter Start Date] AND [Enter End Date]))
    UNION
    SELECT "Workstations Tested" AS PCEQUIP, Count(*) AS RECORDS
    FROM [WORKSTATION]
    WHERE (((Date)Between [Enter Start Date] AND [Enter End Date]))
    UNION
    SELECT "Printers Tested" AS PCEQUIP, Count(*) AS RECORDS
    FROM [PRINTER]
    WHERE (((Date)Between [Enter Start Date] AND [Enter End Date]))
    UNION
    SELECT "Servers Tested" AS PCEQUIP, Count(*) AS RECORDS
    FROM [SERVER]
    WHERE (((Date)Between [Enter Start Date] AND [Enter End Date]))
    )

    Again it works great.



    I have been trying for a days to combine the results of these two queries into one report with the end result of having the PC equipment tested in a report form and the results tallied up as a total pieces of equipment tested. Is this possible? I have looked at the SQL functions and thought that OUTERJOIN may be the closest function to use, but I cannot figure out the syntax and I am not sure if that is the function to use. Does anyone know this could be achieved? Any help would be most appreciated.


    Thank you.


    //m0aje//

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Why don't you use the first query as report RecordSource and do the summary calc in report header/footer section with expression in textbox: =Sum([Records])?
    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
    m0aje is offline Novice
    Windows XP Access 2000
    Join Date
    Nov 2012
    Posts
    10
    Quote Originally Posted by June7 View Post
    Why don't you use the first query as report RecordSource and do the summary calc in report header/footer section with expression in textbox: =Sum([Records])?

    Thanks. I hadn't thought of that. I will give that a try.

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

Similar Threads

  1. Replies: 21
    Last Post: 04-03-2013, 12:51 PM
  2. Replies: 1
    Last Post: 12-23-2012, 08:32 PM
  3. Replies: 1
    Last Post: 10-23-2012, 02:04 PM
  4. Combining Results of Cross Tab Queries
    By kkyork in forum Queries
    Replies: 4
    Last Post: 06-06-2012, 09:10 AM
  5. Replies: 3
    Last Post: 05-21-2010, 03:57 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