Results 1 to 5 of 5
  1. #1
    kattatonic1 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Location
    Toronto, Canada
    Posts
    77

    Unhappy Need query results to include records with no match in joined table

    Hello,

    I have two tables: tblPositions and tblEmployees.
    The field pkPosition# is the unique key in tblPositions.
    I use fkPosition# in tblEmployees to join the tables in queries.
    Most positions have at least one employee, but some positions are vacant.
    Most Employees have an fkPosition#, but some employees don't have a Position# yet. (Not yet assigned by another department.)


    When I choose the option "Include ALL records from tblPositions and only those records from tblEmployees where the joined fields are equal", Access appears to only be returning the records that have matches. I have several scenarios where I require ALL the position data plus any employee data that goes with it, including positions that match to no employee data right now.

    Any help would be appreciated!

    Kay


    from frozen Toronto

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Does your data model match your business rules/needs?
    In general, you have Employee, Position and a junction table such as EmployeeOccupiesPosition.
    Where EmployeeOccupiesPosition has either a compound PK EmployeeId + PositionID, or its own PK EmpOccPosID and a unique composite index on
    EmployeeId + PositionID.

    I suggest you review your table and relationship structure.

    Good luck from Ottawa -20C

  3. #3
    kattatonic1 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Location
    Toronto, Canada
    Posts
    77
    Hey Orange in Ottawa,

    I discovered my query criteria was not right. Was filtering out certain statuses and I had done it backwards!

    However, your advice helped me fix another relationship that would have been an issue; so reviewing the relationships again at this point was helpful.

    Many thanks!
    Stay warm,

    Kay

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Happy to help.
    You have your power back !!!!

  5. #5
    kattatonic1 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Location
    Toronto, Canada
    Posts
    77
    Yes! Thank goodness. Four days without for us, 5 days for my poor ol' parents, 7 for my brother's house. Oh well. Now it's just another good Christmas story.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-04-2013, 01:23 PM
  2. Query results to include descriptions
    By funkygoorilla in forum Queries
    Replies: 4
    Last Post: 02-07-2012, 11:07 AM
  3. Lookup name in a query on a non-joined table
    By karmacable in forum Queries
    Replies: 7
    Last Post: 09-21-2011, 09:01 AM
  4. Replies: 1
    Last Post: 03-09-2011, 02:04 AM
  5. Replies: 0
    Last Post: 02-24-2010, 12:56 AM

Tags for this Thread

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