Results 1 to 2 of 2
  1. #1
    bshaw03 is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    1

    Query doubling results

    Hello,



    I am fairly new to access but thought I was getting the hang of it until I ran into this roadblock. I have 4 tables that I'm attempting to pull data from and put into a query. When I create the queries on an individual basis, they work fine (1 query for 3 of the tables). However, when I create one for all four tables at the same time, I am getting duplicate lines of data when certain elements are added to the "Group By" portion of the query. I have placed 3 queries SQL below - the first two work perfectly fine while the last one works up until the point that I add Funding and any associated elements from that table to the Group By portion of the query - then it doubles certain values under the cost part of the query as well as the funding portion. I know there is no duplicate data in the tables because it pulls correctly for the first two queries.

    (1) QryValue - Designed to pull the value of given efforts

    SELECT TblContract.[Cont_#], TblContract.[DO_#], TblCLIN.[CLIN_#], TblCLIN.CLIN_Type, TblCLIN.[Mod_#], TblValue.Cost_Value, TblValue.COM_Value, TblValue.Fee_Value, TblValue.Price_Value
    FROM (TblContract INNER JOIN TblCLIN ON (TblContract.[Cont_#] = TblCLIN.[Cont_#]) AND (TblContract.[DO_#] = TblCLIN.[DO_#])) INNER JOIN TblValue ON (TblCLIN.[Cont_#] = TblValue.[Cont_#]) AND (TblCLIN.[DO_#] = TblValue.[DO_#]) AND (TblCLIN.[CLIN_#] = TblValue.[CLIN_#]) AND (TblCLIN.[Mod_#] = TblValue.[Mod_#])
    GROUP BY TblContract.[Cont_#], TblContract.[DO_#], TblCLIN.[CLIN_#], TblCLIN.CLIN_Type, TblCLIN.[Mod_#], TblValue.Cost_Value, TblValue.COM_Value, TblValue.Fee_Value, TblValue.Price_Value;

    (2) QryFunding - Designed to pull the funding of given efforts

    SELECT TblContract.[Cont_#], TblContract.[DO_#], TblCLIN.[CLIN_#], TblCLIN.CLIN_Type, TblCLIN.[Mod_#], TblFunding.Cost_Funding, TblFunding.COM_Funding, TblFunding.Fee_Funding, TblFunding.Total_Funding, TblFunding.ACRN, TblFunding.Appropriation
    FROM (TblContract INNER JOIN TblCLIN ON (TblContract.[DO_#] = TblCLIN.[DO_#]) AND (TblContract.[Cont_#] = TblCLIN.[Cont_#])) INNER JOIN TblFunding ON (TblCLIN.[Mod_#] = TblFunding.[Mod_#]) AND (TblCLIN.[DO_#] = TblFunding.[DO_#]) AND (TblCLIN.[CLIN_#] = TblFunding.[CLIN_#]) AND (TblCLIN.[Cont_#] = TblFunding.[Cont_#])
    GROUP BY TblContract.[Cont_#], TblContract.[DO_#], TblCLIN.[CLIN_#], TblCLIN.CLIN_Type, TblCLIN.[Mod_#], TblFunding.Cost_Funding, TblFunding.COM_Funding, TblFunding.Fee_Funding, TblFunding.Total_Funding, TblFunding.ACRN, TblFunding.Appropriation;

    (3) Qry1 - Designed (or trying to at least) to show the value and funding for given efforts at the same time

    SELECT TblContract.[Cont_#], TblContract.[DO_#], TblCLIN.[CLIN_#], TblCLIN.CLIN_Type, TblCLIN.[Mod_#], TblValue.Cost_Value, TblValue.COM_Value, TblValue.Fee_Value, TblValue.Price_Value, TblFunding.Cost_Funding, TblFunding.COM_Funding, TblFunding.Fee_Funding, TblFunding.Total_Funding, TblFunding.ACRN, TblFunding.Appropriation
    FROM ((TblContract INNER JOIN TblCLIN ON (TblContract.[Cont_#] = TblCLIN.[Cont_#]) AND (TblContract.[DO_#] = TblCLIN.[DO_#])) INNER JOIN TblValue ON (TblCLIN.[CLIN_#] = TblValue.[CLIN_#]) AND (TblCLIN.[Cont_#] = TblValue.[Cont_#]) AND (TblCLIN.[DO_#] = TblValue.[DO_#]) AND (TblCLIN.[Mod_#] = TblValue.[Mod_#])) INNER JOIN TblFunding ON (TblCLIN.[CLIN_#] = TblFunding.[CLIN_#]) AND (TblCLIN.[Cont_#] = TblFunding.[Cont_#]) AND (TblCLIN.[DO_#] = TblFunding.[DO_#]) AND (TblCLIN.[Mod_#] = TblFunding.[Mod_#])
    GROUP BY TblContract.[Cont_#], TblContract.[DO_#], TblCLIN.[CLIN_#], TblCLIN.CLIN_Type, TblCLIN.[Mod_#], TblValue.Cost_Value, TblValue.COM_Value, TblValue.Fee_Value, TblValue.Price_Value, TblFunding.Cost_Funding, TblFunding.COM_Funding, TblFunding.Fee_Funding, TblFunding.Total_Funding, TblFunding.ACRN, TblFunding.Appropriation


    Any help would be greatly appreciated. Thanks so much.

    Billy

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    I suspect 2 or more tables in this query are the 'many' side of relationship with another table.

    Want to provide db for analysis? Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Query contents are deleted after exporting the query results
    By alfcee in forum Import/Export Data
    Replies: 6
    Last Post: 11-13-2012, 09:35 AM
  2. Replies: 8
    Last Post: 10-22-2012, 07:43 PM
  3. Add new query results to old one.
    By omair1051992 in forum Queries
    Replies: 1
    Last Post: 06-20-2012, 10:36 AM
  4. Replies: 6
    Last Post: 05-14-2012, 07:24 AM
  5. cbo to filter results from a query
    By nianko in forum Forms
    Replies: 5
    Last Post: 08-18-2010, 09:43 AM

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