Results 1 to 4 of 4
  1. #1
    gaurav2310 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    5

    Smile Find unmatch data from another table with two critreria

    Hi All,

    Need help on one of the queries i am trying to make. I want to extract unmatched data based on two criteria.

    I have two tables:-

    TblCoDetails having fields - RegnNumber CoName
    TblDetails having fields - RecordNo CoName FinancialYear Product CostPrice SalesPrice

    I want the name of company whose data is not yet entered into TblDetails based on FinancialYear criteria.

    For e.g. if in TblCoDetails i have 5 companies A,B,C,D and E.
    And in TblDetails I have 3 records for Co A,D and E for the FinancialYear 2013-2014.
    My tables have one to many relationship and are connected with join properties 2 (Left Join).
    I want a query which will give me a result of B and C as an answer, because data of these two companies are not yet entered for that particular FinancialYear.

    Thanking you in anticipation.

    Regards,
    Gaurav



  2. #2
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    Simply add the year as a calculated field using a subquery:
    SELECT RegnNumber, TblCoDetails.CoName FROM (SELECT *.TblCoDetails, [YearToCheck] AS SelectedYear) AS TblCoDetails LEFT JOIN TblDetails ON TblCoDetails.RegnNumber = TblDetails.RecordNo AND TblCoDetails.CoName = TblDetails.CoName AND TblCoDetails.SelectedYear = TblDetails.FinancialYear WHERE TblDetails.RecordNo IS NULL

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You should not be linking these two tables on the company name. your table tblDetails should have the RegnNumber (assuming that is unique and does not change over time). Linking any two tables via a text string that the users have the ability to change is asking for trouble in a big way. If RegnNumber is a company assigned value (and therefore also changable) you should add an autonumber field to that table and use the autonumber field as your link.

    Secondly do you have another table that tells you what the relationship between the companies and the parent are? If you don't then you would likely be doing this comparison from the previous year to the current year.

  4. #4
    gaurav2310 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    5
    Thanks for the reply hapm.

    I want to select CoName and not RegnNumber. And also RegnNumber <> RecordNo.

    RecordNo is an Autonumber field and is not related to RegnNumber.

    TblCoDetails primary key is CoName which is connected to CoName of TblDetails.

    Thanks & Regards,
    Gaurav

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

Similar Threads

  1. Unmatch Query
    By NOEL71 in forum Queries
    Replies: 1
    Last Post: 06-18-2014, 06:55 AM
  2. Replies: 2
    Last Post: 08-10-2013, 06:06 PM
  3. Match/Unmatch Query need
    By kwooten in forum Queries
    Replies: 5
    Last Post: 11-08-2012, 01:26 PM
  4. Replies: 4
    Last Post: 07-09-2012, 01:49 PM
  5. Replies: 8
    Last Post: 03-22-2012, 08:48 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