Results 1 to 4 of 4
  1. #1
    smeghead67 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    31

    Lightbulb Query to show which employee is not listed in another query

    Hello,

    I am working on a secret shopper database for the employees in my department.

    I have employee info eg. employee id, first, last names in table emp. I have the fields named as emp.empid, emp.first emp.last



    I have the shopping report info eg. employee id, date and time in table shop. I have the fields named as shop.empid shop.dt The employee id field [shop].[empid] is in a relationship with the [emp].[empid] field

    my basic query to look at the info is [getshop]
    Code:
    SELECT emp.last, emp.first, shop.empid, shop.dt
    FROM emp INNER JOIN shop ON emp.empid=shop.empid;
    now to get a count of how many times a person has been shopped i run the [shopped] query
    Code:
    SELECT DISTINCTROW getshop.empid, getshop.first, getshop.last, Count(*) AS TS
    FROM getshop
    GROUP BY getshop.empid, getshop.first, getshop.last;
    This gives me a list of people who have been shopped and how many times they have been shopped.

    now, I want a query called [notshopped] that will give me a list of people who have not been shopped yet.

    The best i have came up with is
    Code:
    SELECT emp.empid, emp.first, emp.last
    From emp
    Where [emp].[empid] <> [getshop].[empid]
    But it asks me for the value of [getshop].[empid]

    Could the wonderful coders of AccessForums.net point me in the correct direction?

    Thank you
    Ted
    Last edited by smeghead67; 03-07-2013 at 09:41 AM. Reason: solved

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try the unmatched query wizard to compare the query of shopped against the table of all.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    smeghead67 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    31
    Thank you Paul,

    I didn't think to check the wizard as I tend to write all my queries by hand. The wizard gave me the following code.

    Code:
    SELECT emp.last, emp.first
    FROM emp LEFT JOIN shopped ON emp.[empid] = shopped.[empid]
    WHERE (((shopped.empid) Is Null));
    I can work from there, thank you again.

    Ted

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

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

Similar Threads

  1. Replies: 3
    Last Post: 09-16-2012, 12:34 AM
  2. Filtering employee id with query on a form
    By stylar in forum Queries
    Replies: 1
    Last Post: 04-23-2012, 06:01 PM
  3. Calendar to show employee schedules
    By Astron2012 in forum Access
    Replies: 1
    Last Post: 03-28-2012, 03:29 PM
  4. Replies: 1
    Last Post: 03-02-2009, 10:12 PM
  5. Replies: 5
    Last Post: 05-02-2006, 11:25 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