I'm getting the error "The multi-part identifier 'MS2.ExtraValueID' cannot be bound" when trying to run the following SQL query in Access 2010.
SELECT [Contact Details].ContactID
FROM ([Contact Details] LEFT JOIN [Extra Fields - Newsletters & Bulletins] ON [Contact Details].ContactID = [Extra Fields - Newsletters & Bulletins].ContactID) LEFT JOIN [Extra Fields - Number of Employees] ON [Extra Fields - Newsletters & Bulletins].ContactID = [Extra Fields - Number of Employees].ContactID;
ExtraValueID appears in the WHERE clause of both of the "Extra Value..." queries, but isn't outputted.
Looking up this question from a few years back, it suggests this is probably due to a typo. However, I can't see anything wrong with the above SQL, which would suggest one of the individual queries which make up this bigger query is wrong.
However, each of the queries individually runs fine, and if I only try to join one of the Extra Fields tables to it, it works fine. I thought the ampersands might be causing an issue, but replacing them with "and", or deleting them altogether makes no difference.
If I replace the LEFT JOIN
s with INNER JOIN
s, it works inasmuch as it returns results, but not the results I want, because I should return all the results from Contact Details whether there are matching records in the two Extra Fields tables or not.
SELECT [Contact Details].ContactID, [Contact Details].[Client Code], [Extra Fields - Newsletters & Bulletins].Newsletters, [Extra Fields - Number of Employees].[Number of Employees]
FROM ([Contact Details] INNER JOIN [Extra Fields - Newsletters & Bulletins] ON [Contact Details].ContactID = [Extra Fields - Newsletters & Bulletins].ContactID) INNER JOIN [Extra Fields - Number of Employees] ON [Extra Fields - Newsletters & Bulletins].ContactID = [Extra Fields - Number of Employees].ContactID;