Forum Discussion

MaxCA1000's avatar
MaxCA1000
Copper Contributor
Jul 06, 2021

Joined Table Not Returning Expected Dataset

My database has two main tables populated by data imported from Excel - data that I've downloaded from my brokerage account and that originates in CSV format that I've saved in Excel format.   The ...
  • isladogs's avatar
    isladogs
    Jul 08, 2021

    MaxCA1000 

    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

Resources