Results 1 to 2 of 2
  1. #1
    WickidWe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    123

    combining queries

    Hi,

    I have a working query that displays the outcome based on form values entered.
    this is my original query called qryAvailable (sorry its a bit long and messy.)
    Code:
    SELECT DISTINCT tblEmpDetails.EmpId, tblFunctions.FctnDesc, tblEmpDetails.EmpNo, tblEmpDetails.Name, tblFunctions.ReliefCode, tblRelief_Allot.GrRating
    FROM (((tblFunctions INNER JOIN ((tbl_shift INNER JOIN tblEmpDetails ON tbl_shift.ShiftCode = tblEmpDetails.Shift) INNER JOIN tblRelief_Allot ON tblEmpDetails.EmpID = tblRelief_Allot.EmpId) ON tblFunctions.ReliefCode = tblRelief_Allot.ReliefCode) INNER JOIN (tblDates INNER JOIN tblRoster ON tblDates.Day_Code = tblRoster.Day_Code) ON (tblEmpDetails.Roster = tblRoster.Roster) AND (tblEmpDetails.Shift = tblRoster.Shift)) INNER JOIN qryEmpLeave ON tblEmpDetails.EmpId = qryEmpLeave.EmpId) INNER JOIN qryNotExempt ON tblEmpDetails.EmpId = qryNotExempt.EmpID
    WHERE (((tblEmpDetails.IsVisible)=True) AND ((tblDates.Date_) Like [Forms]![Form1]![txtDate]) AND ((tblEmpDetails.Shift) Like [Forms]![Form1]![cboShift]) AND ((tblRelief_Allot.ReliefCode) Like [Forms]![Form1]![cboFunction]) AND ((tblDates.Day_Name) Like [Forms]![Form1]![txtDay]) AND ((tblEmpDetails.AlternateDuties)=False))
    ORDER BY tblEmpDetails.Name;
    I have two working queries that I would like to encorporate into the qryAvailable.

    overview:
    qryAvailable selects the names of people available for specific functions based on the date and the shift that works on that date.
    The queries I want to add are for employees who have "Swap Days" (not on there regular shift for selected days)

    the following queries work how I need them to on their own, but I am not sure how to put it all together

    (shows only the team member that I need to Add to the original qryAvailable list)
    qrySwpOn
    Code:
    SELECT tblSwpDay.EmpID, tblFunctions.FctnDesc, tblEmpDetails.EmpNo, tblEmpDetails.Name, tblRelief_Allot.ReliefCode, tblRelief_Allot.GrRating
    FROM ((tblSwpDay INNER JOIN tblRelief_Allot ON tblSwpDay.EmpID = tblRelief_Allot.EmpId) INNER JOIN tblFunctions ON tblRelief_Allot.ReliefCode = tblFunctions.ReliefCode) INNER JOIN tblEmpDetails ON tblSwpDay.EmpID = tblEmpDetails.EmpId
    WHERE (((tblRelief_Allot.ReliefCode)=[Forms]![Form1]![cboFunction]));
    (Shows Everyone on the qryAllocated list, Exept the Person I no longer need)
    qrySwpOff
    Code:
    SELECT *
    FROM qryAvailable AS QA
    WHERE QA.EmpId Not In (SELECT TSD.EmpID
         FROM tblSwpDay AS TSD
         WHERE [Forms]![Form1]![txtDate] = TSD.[New Off]);
    I need to show all of (qryAvailable + qrySwpOn) - qrySwpOff



    is this even possible?

    thanks in advance.

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    You can combine multiple queries of course. You don't subtract queries, just the results of the query. Queries just like tables need to be joined by like fields unless it is a Cartesian Query.

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

Similar Threads

  1. Combining two queries.
    By Ray67 in forum Queries
    Replies: 1
    Last Post: 09-07-2012, 12:11 PM
  2. Combining queries..
    By Anthony88 in forum Queries
    Replies: 4
    Last Post: 05-02-2012, 02:46 PM
  3. Combining two queries
    By Adele in forum Queries
    Replies: 1
    Last Post: 07-16-2011, 12:17 AM
  4. Combining queries
    By wildlifeaccess in forum Queries
    Replies: 10
    Last Post: 09-20-2010, 07:35 AM
  5. Combining Two Queries
    By csolomon in forum Queries
    Replies: 1
    Last Post: 09-03-2009, 01:33 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