Results 1 to 8 of 8
  1. #1
    @MeDaveT is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    3

    Query for identifying Docs with different owners

    Wondering if anyone can help



    I have an Access db with two tables which detail documents and there owners (up to 10 owners).

    I am trying to come up with a query which will show me the names of the documents which don't have matching owners (Note owners could be in different order as per the attachment).
    Attached Files Attached Files

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    Your data is not normalised each table should be structured as

    DocID autonumber
    DocName text
    Owner Text

    then it would be easy for a simple comparison - to find owners in table1 who are not in table2

    Code:
    SELECT *
    FROM table1 left join table2 on table1.docname=table2.docname and table1.owner=table2.owner
    where table2.docid is null
    and owners in table2 not in table1
    Code:
    SELECT *
    FROM table1 right join table2 on table1.docname=table2.docname and table1.owner=table2.owner
    where table1.docid is null

    With your data as you have it structured you would have to compare each column in table1 with 10 columns in table2 and then the reverse - 200 comparisons

  3. #3
    @MeDaveT is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    3
    Thanks but what I am looking for is a query which will simply return a list of documents where the owners don't match i.e. using the data in the attachment the query should return BlueberryPieRecipe

  4. #4
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    OK - in that case you just need 100 queries - take the first of my queries as a model then instead of just comparing owner to owner you need

    table1-owner1 match to table2 - owner1
    table1-owner1 match to table2 - owner2
    ....
    ....
    table1-owner2 match to table2 - owner1
    table1-owner2 match to table2 - owner2

    you would probably want to connect these 100 queries in a union query

  5. #5
    @MeDaveT is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    3
    100 queries !!!!!

    On that basis using Access might not be a feasible option.

  6. #6
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    It is only because you have your data set up like Excel rather than as a database. Set your data up as I suggested and you just need the two queries

    Excel data is short and wide, databases are tall and narrow

    How would you do it in Excel?

  7. #7
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    If your owners are always in the same order for any given docname then you could do something like

    Select table1.*
    FROM table1 left join table2 on table1.docname=table2.docname and table1.owner1=table2.owner1 and table1.owner2=table2.owner2....
    where table2.docname is null

    which is just one query, but you said
    Note owners could be in different order as per the attachment
    so I presumed this would not work

  8. #8
    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,870
    It isn't Access that is the issue. You are not using Access(relational database) as it was intended.
    it's a little bit like using a monkey wrench as a hammer.

    You really should do some research Normalization, Relational database design principles.

    Don't blame the tool if you don't know how to use it.

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

Similar Threads

  1. Google docs & email
    By Historypaul in forum Import/Export Data
    Replies: 0
    Last Post: 02-17-2013, 10:51 PM
  2. Replies: 11
    Last Post: 04-19-2012, 03:28 PM
  3. Generate docs from MS access
    By matspring in forum Access
    Replies: 2
    Last Post: 05-07-2011, 07:48 PM
  4. Creating Links to Word Docs
    By kingharvest in forum Access
    Replies: 1
    Last Post: 05-19-2010, 10:28 PM
  5. word docs.
    By laqsb in forum Access
    Replies: 1
    Last Post: 02-26-2010, 08:50 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