简体   繁体   English

Access 2016-将链接的Excel Tbl制成Qry-尝试“不匹配”时获取数据类型不匹配

[英]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 -> Excel文件链接作为表格[tbl_Mast_CC_List],我通过查询将可能的“成本中心编号”转换为安全性值,“成本中心”中没有文本变量或前000个,下箭头

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

-> then I create the Unmatched Query, here is the SQL: ->然后创建不匹配查询,这是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. 您的问题可能是由于使用val()函数并尝试针对null进行测试。 My understanding is that val() doesn't return nulls, it returns 0 when it can't find anything. 我的理解是val()不返回null,在找不到任何东西时返回0。 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. 您最好以相反的方向运行转换,即在数字CostCenter字段上使用CStr()并将其与Excel中的文本数据进行比较。

Alternately you could change the Excel field itself to a number format instead of text. 或者,您可以将Excel字段本身更改为数字格式,而不是文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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