Results 1 to 4 of 4
  1. #1
    hotpants49 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    2

    Excluding values based on another table

    I have two tables:

    Employees and Holidays.

    Table Employees contains a list of employee names that I want to be able to choose from when selecting a person for a shift (im building a roster system). Holidays contains two fields, employee name and day off.

    The relationship between the two tables is a one to many, Employees being the one and Holidays being the many - linked with employee name. Each person might have a few dozen entries into holidays for various days off

    The form that I have made so far has a text box on it called datebox, which is the day that you are entering the shifts for.

    What I would like is for the user to be unable to select a persons name for a shift if they are in the holidays table as having a day off on the same date as in datebox

    I know I need to make a query to do this but all the critera (using one query) I tried so far seems to only want to either return every name, not filtering out any that are down for holidays, or only the ones that are down for holidays instead of the ones that arent.

    I tried making two querys:



    queryp1 - Has two fields. One is [Holidays].[Employee Name] and the other is [Holidays].[Day Off]. I used [Forms]![Shift Entry]![datebox] as a criteria on the [Holidays].[Day Off] field to only return the names of people who ARE on holidays for that day.
    This part works fine

    queryp2 - lists all of the names in [Employees].[Employee Name] with a criteria of Not Like [Queryp1]![Employee Name] however a input box comes up asking for the field [Queryp1]![Employee Name]. If I add the query into the tables area at the top then I end up with multiple results for every person because each person has multiple entries in the Holidays table the queryp1 is based on.

    I'm really stuck with this one, and don't have a real lot of experience with access besides making another DB for invoices. Any help would be greatly appreciated.

    I hope all that made sense

  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, comparing your first query against the table of all employees.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    hotpants49 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    2
    Can't believe it was as simple as changing what type of query I was running. Thanks so much for the help, works great

  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
    Happy to help, and welcome to the site by the way!
    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: 14
    Last Post: 09-21-2012, 11:12 AM
  2. Replies: 2
    Last Post: 05-21-2012, 02:06 PM
  3. Replies: 3
    Last Post: 02-23-2012, 06:29 PM
  4. Excluding null values on SQL table query
    By DB2010MN26 in forum Queries
    Replies: 1
    Last Post: 09-03-2010, 12:54 PM
  5. Replies: 4
    Last Post: 02-08-2010, 11:17 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