Results 1 to 6 of 6
  1. #1
    buckmurdock is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Posts
    4

    Unmatch query of sorts

    Hello everyone, I apologize if this question has been asked before, i searched the forums and didn't see anything that seemed to get at what I'm looking to do.



    I have two tables that i'm trying to compare and I want to get a full list of the difference, not just the fields that don't match.

    I have a table of Job Positions and the various accounts that each one is paid for, and I have a table of the new upcoming budget which has the Job Positions and the accounts that are used to pay each one. Some of these jobs are split (50/50, or 70/30 or 50/30/20, etc.). I would like to find all the jobs in the new budget table and list out the account number and the percentages.

    I'm almost there, i did an unmatch query, but it only shows me the differences, I'd like it to show me the job positions that are different but still list out the account numbers and percentages, so that we can do through and true up the first database with the new info. Hopefully, my example below will help explain it.

    Table 1(Budget Positions - These will be the changes entered into the HR database)
    Job Code Account Pct
    1464 0014510 10%
    1464 0014523 5%
    1464 0014524 10%
    1464 0014526 5%
    1464 0014527 5%
    1464 0014528 5%
    1464 0014543 20%
    1464 0014570 20%
    1464 0014571 10%
    1464 0014572 5%
    1464 0014573 5%




















    Table 2 (Job Positions - Currently in HR database)
    Job Code Account Pct
    1464 0014510 10%
    1464 0014523 5%
    1464 0014526 5%
    1464 0014528 5%
    1464 0014570 55%
    1464 0014571 10%
    1464 0014572 5%
    1464 0014573 5%
















    The query I've managed to make so far will show me the items that exist in Table 1 but not in Table two but it only shows me the 4 items that dont match. What I would really like is for it to show me a table of all the Job Codes where there is a mismatch, but also show me all the rows associated with that Job code, so when we're updating the database we know all the account numbers and percentages to enter in.

    so instead of showing me:
    1464 0014543 20%
    1464 0014527 5%
    1464 0014524 10%
    1464 0014570 20%

    It would just show all the lines that have Job Code 1464 from Table 1. If the Job code, account and percentage match between the two tables dont show anything, but if there's a mismatch on any one of those 3 columns for that specific job code then show me all the rows from table 1.

    I hope that explains what i'm trying to do, until I started working here previous co-workers would manually go through the list in spreadsheets line by line and find the differences. i'm too lazy for this manual method, and I think what i've already come up with is good enough, but figured in the off chance it's needed I would ask to see if the method i explained is possible.

    Thank you in advance for your help with that, i greatly appreciate it.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Can you create a new query that is not an unmatched query and then bring your other query (the unmatched query) in as a sub-query, joining on Job Code?

  3. #3
    buckmurdock is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Posts
    4
    I'm not sure i follow exactly, i tried to compare the results of my unmatched query against Table 1 in a new query, joining on the Job Code, and it almost seemed like that was the right answer (maybe it's on the right path) but i noticed on some of the Job Codes it would have one or more duplicate rows.

  4. #4
    buckmurdock is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Posts
    4
    I'm not sure i follow exactly, i tried to compare the results of my unmatched query against Table 1 in a new query, joining on the Job Code, and it almost seemed like that was the right answer (maybe it's on the right path) but i noticed on some of the Job Codes it would have one or more duplicate rows.

  5. #5
    buckmurdock is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Posts
    4

    Here's an example

    Sorry about the double post i was trying to figure out how to attach an example database (which should hopefully be attached now).

    The data I'm working off of is actually two separate spreadsheets, but I went ahead and imported them as tables for now. I removed all the unnecessary information, so they both have the same 3 columns (Job Code, Account and Pct).

    I deleted my Unmatched query, because after looking at it again it was just showing all 831 rows from the NewBudgetPositions table and not just the differences so its just the 2 tables right now, and all i want to do is see what exists in the Budget table that doesnt exist in the Current table.
    Attached Files Attached Files

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I took a look at the DB and I think I understand you need to get the records that changed in NewBudgetPositions into CurrentPositions. I split it up into two steps. First I found records that did not exist in CurrentPositions based on Job Codes.
    Created unmatched query Wizard for Job Codes in tblNewBudget that are not in tblCurrentPositions
    Produces 583 records
    Code:
    SELECT NewBudgetPositions.[Job Code], NewBudgetPositions.Account, NewBudgetPositions.Pct
    FROM NewBudgetPositions LEFT JOIN CurrentPositions ON NewBudgetPositions.[Job Code] = CurrentPositions.[Job Code]
    WHERE (((CurrentPositions.[Job Code]) Is Null));
    Used the above query in an APPEND query and appended those records to CurrentPositions Current Positions went from 390 to 973 records. I deleted the APPEND query from the sample DB.

    Then did an Unmatched Query using table NewBudgetPositions as the table no related records in CurrentPositions, JOINING on Pct. This resulted in 89 records. I believe these records are the ones you want to UPDATE in CurrentPositions.

    This is the SQL for the second Unmatched Query
    Code:
    SELECT NewBudgetPositions.[Job Code], NewBudgetPositions.Pct
    FROM NewBudgetPositions LEFT JOIN CurrentPositions ON NewBudgetPositions.[Pct] = CurrentPositions.[Pct]
    WHERE (((CurrentPositions.Pct) Is Null));
    So you still need to UPDATE those 89 records but wanted to make sure this is the direction you needed to go in.
    Attached Files Attached Files

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

Similar Threads

  1. Query to find unmatch data between two tables
    By MTSPEER in forum Queries
    Replies: 10
    Last Post: 01-29-2015, 10:48 AM
  2. Unmatch Query
    By NOEL71 in forum Queries
    Replies: 1
    Last Post: 06-18-2014, 06:55 AM
  3. Complex Sorts in Datasheet View
    By Paul H in forum Forms
    Replies: 4
    Last Post: 05-09-2014, 10:10 AM
  4. Match/Unmatch Query need
    By kwooten in forum Queries
    Replies: 5
    Last Post: 11-08-2012, 01:26 PM
  5. Sort - of sorts
    By Needlejockey in forum Reports
    Replies: 5
    Last Post: 04-13-2012, 01:51 PM

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