Forum Discussion
Joined Table Not Returning Expected Dataset
- Jul 08, 2021
Thanks for sending me the cut down version of the database
Problem solved. It’s a data issue with the Symbol field when imported from Excel.
When you imported your Excel data to tblDivReceived, the Symbol field had a leading space.
However, there is no leading space for that field in tblHoldings.
Compare the field lengths using the following queries:
SELECT DISTINCT tblDivReceived.Symbol, Len([Symbol]) AS LenSymbol
FROM tblDivReceived
ORDER BY tblDivReceived.Symbol;
And
SELECT tblHoldings.Symbol, Len([Symbol]) AS LenSymbol
FROM tblHoldings;
So the fields are never identical and the table join fails.
To fix the issue with your current dataset, run this update query to remove the leading space using the Trim function:
UPDATE tblDivReceived SET tblDivReceived.Symbol = Trim([Symbol]);
You will then find the qryTrueData works perfectly
To avoid the problem with future Excel imports, use the Trim function on the Excel data before import or when you import
I restored the leading space in the file I've sent back to you by email so you can check all this for yourself. Hopefully you’ll be OK from here onwards