Hello All,
I'm trying to open a query and I keep getting the same error message:
"The specified table 'tblPeople.AddressID' could refer to more than one table listed in the FROM clause of the SQL statement."
It seems to me tblPeople.AddressID is very specific and can't be confused for anything else. So I surrounded it in brackets, [tblPeople].[AddressID], and got the same error message including the brackets. I checked and there is only one tblPeople and there is only one field called AddressID contained in tblPeople. (tblPeople.AddressID is only listed in the SQL statement once. qryDirectory1All works fine when opened. AddressID is a PK in tblAddress.) So what's causing the confusion?
Here's my SQL statement:
SELECT make_DirectoryName(IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[FirstName]),IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[LastName]),[qryDirectory2_spouse].[FirstName],[qryDirectory2_spouse].[LastName]) AS DirectoryName, qryDirectory1All.Address, tblFamily.AddressID, qryDirectoryPhoneAll.PhoneType, qryDirectoryPhoneAll.PhoneNumber, tblFamily.OwesHOA, tblFamily.Renter, tblFamily.Owner, tblPeople.EmailAddress, tblFamily.ListAddress, tblPeople_1.[Opt-in]
FROM ((((tblPeople LEFT JOIN qryDirectory2_spouse ON tblPeople.FamilyID = qryDirectory2_spouse.FamilyID) INNER JOIN tblFamily ON tblPeople.FamilyID = tblFamily.FamilyID) INNER JOIN tblPeople AS tblPeople_1 ON tblPeople.FamilyID = tblPeople_1.FamilyID) INNER JOIN qryDirectory1All ON tblPeople.AddressID = qryDirectory1All.AddressID) LEFT JOIN qryDirectoryPhoneAll ON tblPeople.FamilyID = qryDirectoryPhoneAll.FamilyID
WHERE (((tblPeople.PKRelationship)=1 Or (tblPeople.PKRelationship)=2) AND ((tblPeople_1.PKRelationship)=1))
GROUP BY make_DirectoryName(IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[FirstName]),IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[LastName]),[qryDirectory2_spouse].[FirstName],[qryDirectory2_spouse].[LastName]), qryDirectory1All.Address, tblFamily.AddressID, qryDirectoryPhoneAll.PhoneType, qryDirectoryPhoneAll.PhoneNumber, tblFamily.OwesHOA, tblFamily.Renter, tblFamily.Owner, tblPeople.EmailAddress, tblFamily.ListAddress, tblPeople_1.[Opt-in]
ORDER BY make_DirectoryName(IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[FirstName]),IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[LastName]),[qryDirectory2_spouse].[FirstName],[qryDirectory2_spouse].[LastName]), qryDirectoryPhoneAll.PhoneType DESC;
Thanks
I'm trying to open a query and I keep getting the same error message:
"The specified table 'tblPeople.AddressID' could refer to more than one table listed in the FROM clause of the SQL statement."
It seems to me tblPeople.AddressID is very specific and can't be confused for anything else. So I surrounded it in brackets, [tblPeople].[AddressID], and got the same error message including the brackets. I checked and there is only one tblPeople and there is only one field called AddressID contained in tblPeople. (tblPeople.AddressID is only listed in the SQL statement once. qryDirectory1All works fine when opened. AddressID is a PK in tblAddress.) So what's causing the confusion?
Here's my SQL statement:
SELECT make_DirectoryName(IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[FirstName]),IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[LastName]),[qryDirectory2_spouse].[FirstName],[qryDirectory2_spouse].[LastName]) AS DirectoryName, qryDirectory1All.Address, tblFamily.AddressID, qryDirectoryPhoneAll.PhoneType, qryDirectoryPhoneAll.PhoneNumber, tblFamily.OwesHOA, tblFamily.Renter, tblFamily.Owner, tblPeople.EmailAddress, tblFamily.ListAddress, tblPeople_1.[Opt-in]
FROM ((((tblPeople LEFT JOIN qryDirectory2_spouse ON tblPeople.FamilyID = qryDirectory2_spouse.FamilyID) INNER JOIN tblFamily ON tblPeople.FamilyID = tblFamily.FamilyID) INNER JOIN tblPeople AS tblPeople_1 ON tblPeople.FamilyID = tblPeople_1.FamilyID) INNER JOIN qryDirectory1All ON tblPeople.AddressID = qryDirectory1All.AddressID) LEFT JOIN qryDirectoryPhoneAll ON tblPeople.FamilyID = qryDirectoryPhoneAll.FamilyID
WHERE (((tblPeople.PKRelationship)=1 Or (tblPeople.PKRelationship)=2) AND ((tblPeople_1.PKRelationship)=1))
GROUP BY make_DirectoryName(IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[FirstName]),IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[LastName]),[qryDirectory2_spouse].[FirstName],[qryDirectory2_spouse].[LastName]), qryDirectory1All.Address, tblFamily.AddressID, qryDirectoryPhoneAll.PhoneType, qryDirectoryPhoneAll.PhoneNumber, tblFamily.OwesHOA, tblFamily.Renter, tblFamily.Owner, tblPeople.EmailAddress, tblFamily.ListAddress, tblPeople_1.[Opt-in]
ORDER BY make_DirectoryName(IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[FirstName]),IIf([tblPeople_1].[PKRelationship]=1,[tblPeople_1].[LastName]),[qryDirectory2_spouse].[FirstName],[qryDirectory2_spouse].[LastName]), qryDirectoryPhoneAll.PhoneType DESC;
Thanks