简体   繁体   中英

Access 2016 - Linked Excel Tbl made into Qry - get Data type Mismatch when trying Unmatched

This seems like a very simple question, however, I am still not getting rid of the Data Type Mismatch. Scenario:

-> Excel File link in as table [tbl_Mast_CC_List], I convert the possible Cost Center Numbers into Values for safety via query, there are NO text variables in the Cost Center or preceding 000's, next arrow

-> qry_CC_Clean is CostCenter:Val([tbl_Mast_CC_List.CostCenter])

-> then I create the Unmatched Query, here is the SQL:

SELECT 
    qry_CC_S1_Clean_F2F_Alloc.DataName
    , qry_CC_S1_Clean_F2F_Alloc.Year
    , qry_CC_S1_Clean_F2F_Alloc.CostCenter
FROM qry_CC_S1_Clean_F2F_Alloc 
LEFT JOIN qry_CC_S1_Clean_Mast_CC_List 
    ON qry_CC_S1_Clean_F2F_Alloc.CostCenter = qry_CC_S1_Clean_Mast_CC_List.CostCenter
WHERE (((qry_CC_S1_Clean_Mast_CC_List.CostCenter) Is Null))
ORDER BY qry_CC_S1_Clean_F2F_Alloc.CostCenter;

The only time I can get it to work is if I make table of the query and I don't really want to do that. Any suggestions would be greatly appreciated because I have to run this unmatched query against numerous tables to make sure the company is not missing any cost centers rolling through. Thank you!

Your problem is likely due to using the val() function and trying to test it against nulls. My understanding is that val() doesn't return nulls, it returns 0 when it can't find anything. You might be better off running the conversion in the opposite direction, ie using CStr() on the numeric CostCenter field and comparing that to the text data from Excel.

Alternately you could change the Excel field itself to a number format instead of text.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM