Query join of table duplicates records

Adding the following join duplicates every record doubling the number of records in the below complicated query.  Any ideas to resolve this? I tried DISTINCTROW and changing the Inner Join to a Left Join.

INNER JOIN tblPatientProviderList ON [Complaint List].ComplaintID = tblPatientProviderList.ComplaintID) ON ReferDr.ContactID = tblPatientProviderList.ContactID)

      [Ins2Info.CompanyName]),6) & Format([Provider],
      '00') & [Last Name] & [Visit.ComplaintID] & [Ledger.Status] AS GroupField,
      [CPT code list].CPTCode,
      [Complaint List].MVA,
      [Complaint List].MVAState,
      [Complaint List].WC,
      [Complaint List].OtherAccident,
      IIf([Ins1GroupInfo.Group Number]='None',' ',
      [Ins1GroupInfo.Group Number]) AS Group1Number,
      IIf([Ins2GroupInfo.Group Number]='None',' ',
      [Ins2GroupInfo.Group Number]) AS Group2Number,
      [Patient Information].State,
      [Patient Information].[Postal Code],
      [Patient Information].Sex,
      [Patient Information].[Home Phone],
      [Patient Information].Birthdate,
      [Patient Information].[Last Name],
      [Patient Information].[First Name],
      [Patient Information].[Middle Initial],
      [Patient Information].Address,
      [Patient Information].City,
      [Patient Information].[Marital Status],
      [Patient Information].Employer,
      Provider.UPIN AS ProvUPIN,
      [Resource List].Initials,
      [Resource List].ProviderType,
      [Complaint List].PlaceOfService,
      [Complaint List].TypeOfService,
      IIf([PlaceOfService]>'20' AND
      '') AS AdmDate,
      IIf([PlaceOfService]>'20' AND
      '') AS LastDate,
      (((Contacts AS ReferDr
      INNER JOIN ((([Patient Information]
      INNER JOIN (((((Ledger
      LEFT JOIN [CPT code list] ON Ledger.CPTID = [CPT code list].CPTID)
      INNER JOIN ((((([Complaint List]
      LEFT JOIN [Insurance Group Information] AS Ins1GroupInfo ON [Complaint List].Group1 = Ins1GroupInfo.GroupID)
      LEFT JOIN [Insurance Group Information] AS Ins2GroupInfo ON [Complaint List].Group2 = Ins2GroupInfo.GroupID)
      LEFT JOIN [Insurance Patient Information] AS Ins1PatientInfo ON [Complaint List].Ins1PTID = Ins1PatientInfo.InsPTID)
      LEFT JOIN [Insurance Patient Information] AS Ins2PatientInfo ON [Complaint List].Ins2PTID = Ins2PatientInfo.InsPTID)
      INNER JOIN Visit ON [Complaint List].ComplaintID = Visit.ComplaintID) ON Ledger.VisitID = Visit.VisitID)
      LEFT JOIN [Insurance Companies] AS Ins1Info ON Visit.Ins1ID = Ins1Info.InsCoID)
      LEFT JOIN [Insurance Companies] AS Ins2Info ON Visit.Ins2ID = Ins2Info.InsCoID)
      LEFT JOIN (Contacts AS Provider
      RIGHT JOIN [Resource List] ON Provider.ContactID = [Resource List].ContactID) ON Visit.Provider = [Resource List].ResourceID) ON [Patient Information].PatientID = Visit.PatientID)
      LEFT JOIN Contacts AS Facility ON [Complaint List].Facility = Facility.ContactID)
      INNER JOIN tblPatientProviderList ON [Complaint List].ComplaintID = tblPatientProviderList.ComplaintID) ON ReferDr.ContactID = tblPatientProviderList.ContactID)
      INNER JOIN tblProviderDescription ON [Complaint List].ComplaintType = tblProviderDescription.BillingProviderType)
      INNER JOIN tblPatientProviderList AS tblPatientProviderList_1 ON (tblProviderDescription.ProviderDescriptionID = tblPatientProviderList_1.DescriptionID) AND
      ([Complaint List].ComplaintID = tblPatientProviderList_1.ComplaintID))
      INNER JOIN Contacts AS BillingProvider ON tblPatientProviderList_1.ContactID = BillingProvider.ContactID
      (((Ledger.LedgerID) In (2647,
      6) & Format([Provider],
      '00') & [Last Name] & [Visit.ComplaintID] & [Ledger.Status];
LVL 39
Who is Participating?
peter57rConnect With a Mentor Commented:
Distinct looks at every field in your Select clause.
Are you saying that you have duplicates of entire rows in your output - I suspect that's not what you mean.

If you have 'duplicates' based on some of the fields then you have to look at the tabl(s) that are contributing multiple rows for the same duplicate values.  For each table of this type, you need to create a sub-query to select just the unique records you want . Then use the subqueries instead of the tables in your main query.
thenelsonAuthor Commented:
I found the answer. I need to add "AND ((tblPatientProviderList.DescriptionID)=2)" to the Where clause since the added join added two different sets of valves and I only wanted one of them.

Although I got the solution before reading your comment, I'm going to give you the points since your suggestion is right on and would have led me to the solution if I didn't find it myself.  Thanks for the reply.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.