Results 1 to 5 of 5
  1. #1
    MSandell13 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    3

    Duplicate results for query

    I am running a report in access for my team and have created the query based on live data that we have feeding into access. I have created and run the report but I am seeing duplicate information and I am wondering how to get this down. I also am hoping to after this determine that the report is pulling all necessary data. The data is creating duplicate records for customer names and customer ID's, but I only want one. (this may be pulling duplicates because of other information I am pulling but do not know how to determine this). It's a big report/query and I have pasted the SQL below.





    SELECT dbo_customer.customer_name, dbo_customer.customer_token, [Proposal Status Codes].description1, dbo_underwriter.last_name, dbo_salesperson.lastname, dbo_proposal.effec_date, dbo_customer.state, dbo_producer_company.producer_company_name, dbo_producer_company.state, dbo_producer.firstname, dbo_producer.lastname, dbo_experience_contacts_view.contact_type, dbo_experience_contacts_view.contact_name, Sum(dbo_worksheet.enroll_total) AS SumOfenroll_total, dbo_mgu_representative.first_name, dbo_mgu_representative.last_name, dbo_proposal.renewal INTO Renewals
    FROM (((((((dbo_mgu_representative INNER JOIN ((dbo_producer INNER JOIN dbo_producer_company ON dbo_producer.producer_company_token = dbo_producer_company.producer_company_token) INNER JOIN (dbo_customer INNER JOIN dbo_proposal ON dbo_customer.customer_token = dbo_proposal.customer_token) ON dbo_producer.producer_token = dbo_proposal.producer_token) ON dbo_mgu_representative.mgu_rep_token = dbo_proposal.mgu_rep_token) INNER JOIN dbo_worksheet ON dbo_proposal.proposal_token = dbo_worksheet.proposal_token) INNER JOIN dbo_underwriter ON dbo_proposal.under_token = dbo_underwriter.under_token) INNER JOIN dbo_salesperson ON dbo_proposal.sales_rep_token = dbo_salesperson.salesperson_token) INNER JOIN [Proposal Status Codes] ON dbo_proposal.status = [Proposal Status Codes].value) INNER JOIN dbo_experience_period ON dbo_customer.customer_token = dbo_experience_period.customer_token) INNER JOIN dbo_experience_contacts_view ON dbo_experience_period.exp_period_token = dbo_experience_contacts_view.exp_period_token) INNER JOIN dbo_producer_parent ON dbo_producer_company.parent_company_token = dbo_producer_parent.parent_company_token
    GROUP BY dbo_customer.customer_name, dbo_customer.customer_token, [Proposal Status Codes].description1, dbo_underwriter.last_name, dbo_salesperson.lastname, dbo_proposal.effec_date, dbo_customer.state, dbo_producer_company.producer_company_name, dbo_producer_company.state, dbo_producer.firstname, dbo_producer.lastname, dbo_experience_contacts_view.contact_type, dbo_experience_contacts_view.contact_name, dbo_producer_parent.Parent_company_name, dbo_mgu_representative.first_name, dbo_mgu_representative.last_name, dbo_proposal.renewal
    HAVING (((dbo_proposal.effec_date)=#1/1/2020#) AND ((dbo_experience_contacts_view.contact_type)="01") AND ((dbo_proposal.renewal)="Y"));

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    You are joining multiple tables - should expect 'parent' data to repeat for every 'child' record. This should not be an issue when only 2 tables are involved. However, you have many more tables. If there are multiple many-to-many related tables, use subreports instead of everything in one query.
    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.

  3. #3
    MSandell13 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    3
    Thanks! Do you happen to have any references or documents on how to use subreports so I can break this up appropriately?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Subreports are built same way as subforms. Use Master/Child Links properties to synchronize related records. Search web, I am sure will find tutorials.
    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.

  5. #5
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    Maybe also, to get rid of duplicate records in that query above, you could maybe create new query with the source the first query you pasted above. Then turn on Totals on this 2nd query and have it use Groupby on all the fields. Base your report on this 2nd query. If you are talking about duplicate data in fields on multiple records, on the reports you can put those in group header field areas so they only show once on the report.

    Maybe give an few records example of the data from that query above.

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

Similar Threads

  1. Duplicate results
    By MSB123 in forum Queries
    Replies: 1
    Last Post: 07-11-2019, 11:17 PM
  2. Is my duplicate query duplicating results?
    By rebfein in forum Queries
    Replies: 5
    Last Post: 09-11-2017, 12:23 PM
  3. Highlight Duplicate Values in Query Results
    By TJ1010F in forum Queries
    Replies: 3
    Last Post: 06-21-2015, 05:51 PM
  4. Replies: 6
    Last Post: 06-20-2012, 06:42 AM
  5. Query Brings back duplicate results
    By DaveyJ in forum Queries
    Replies: 1
    Last Post: 06-10-2010, 05:59 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