Results 1 to 6 of 6
  1. #1
    JL2309 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    18

    Query returning fewer results than data table

    I have a table (TBL_Mint_Compounds) with 3326 entries (chemical compounds). Each compound is matched to a master list and returned with additional identifying information, so there should be the same number of entries in the final query (QRY_Mint_CompoundsClean) that exist in the original table. This has been 1:1 for all the other compound groups I've worked with. However, the query is only giving 3304 results - 22 are missing. I already ran a mismatch query to see if any of the compound names were missing from the matching table (TBL_MasterListv15), but it returned 0 results.



    The query SQL is below; thank you in advance for any help/ideas!

    SELECT First(TBL_Mint_Compounds.NCS_FEMA) AS FirstOfNCS_FEMA, First(TBL_MasterListv15.[JECFA Class]) AS [FirstOfJECFA Class], First(TBL_MasterListv15.[DT Class]) AS [FirstOfDT Class], First(TBL_MasterListv15.[FEMA Name]) AS [FirstOfFEMA Name], First(TBL_MasterListv15.[CAS No]) AS [FirstOfCAS No], First(TBL_MasterListv15.[FEMA (derived)]) AS [FirstOfFEMA (derived)], First(TBL_Mint_Compounds.AreaPercentage) AS FirstOfAreaPercentage, First(TBL_Mint_Compounds.AnalysisNo) AS FirstOfAnalysisNo, First(TBL_Mint_Compounds.Company) AS FirstOfCompany, TBL_Mint_Compounds.ID, TBL_Mint_IDnames.FEMAName AS NCSname
    FROM TBL_MasterListv15 INNER JOIN (TBL_Mint_Compounds INNER JOIN TBL_Mint_IDnames ON TBL_Mint_Compounds.NCS_FEMA = TBL_Mint_IDnames.FEMA_NASNo) ON TBL_MasterListv15.[Compound Name] = TBL_Mint_Compounds.[CompoundName]
    GROUP BY TBL_Mint_Compounds.ID, TBL_Mint_IDnames.FEMAName;

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Regress the fields that you are joining on for inconsistent data.

  3. #3
    JL2309 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    18
    Thanks - what does this mean/how do I do that?

  4. #4
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Your query joins different tabls together using specific fields. Query those fields on their own, look for issue. You can also try returning the records that are the negative of your current query. To do the 2nd portion requires changing the queries to operate in left join mode. This joins all the data, you can then tell it to return only data that has nulls for portions of the set.

  5. #5
    nhorton79 is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Apr 2015
    Posts
    34
    I had a similar problem when doing query that referenced multiple tables, records were missing. I used, for example:

    SELECT nz([fieldname],"") AS alias

    This replaces any null fields in the query as a blank.

  6. #6
    JL2309 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    18
    Thank you everyone; I think I may just be too much of a novice to be able to fix this. I am not versed in VBA and think this is a formatting issue/invisible spaces, as most of the data was from different sources and brought in from Excel, but the TRIM function didn't work and I don't know how to implement the suggested fixes

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

Similar Threads

  1. Like query not returning all results
    By robbeh in forum Queries
    Replies: 3
    Last Post: 10-10-2014, 02:32 PM
  2. Cause of fewer records in results?
    By #1Newbie in forum Queries
    Replies: 4
    Last Post: 06-07-2013, 09:47 AM
  3. Query not returning all expected results
    By amenitytrust in forum Queries
    Replies: 6
    Last Post: 11-05-2012, 07:13 AM
  4. Left table NOT returning all results
    By Battlecat in forum Queries
    Replies: 3
    Last Post: 11-02-2011, 08:08 AM
  5. Query not returning all of the results
    By velvettiger in forum Queries
    Replies: 4
    Last Post: 03-11-2010, 06: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