简体   繁体   English

ms Access 2007中条件表达式中的数据类型不匹配错误

[英]Data type mismatch error in criteria expression in ms access 2007

I am trying to run an update query but it is giving me "Data type mismatch in criteria expression". 我正在尝试运行更新查询,但它给我“条件表达式中的数据类型不匹配”。 It was working just fine before but now, all of sudden it started giving me this error. 之前一切正常,但现在突然间,我开始出现此错误。 I tried doing research and also checked in stack overflow but could not find the solution. 我尝试进行研究,还检查了堆栈溢出,但找不到解决方案。 I only have one criteria expression in my query. 我的查询中只有一个条件表达式。

UPDATE dbo_tblGoods INNER JOIN qryValidate
   ON dbo_tblGoods.MaterialID = qryValidate.MaterialID
SET dbo_tblGoods.BarcodeType = [qryValidate]![BarCodeType],
    dbo_tblGoods.BarCode = [qryValidate]![BarCode]
WHERE (((Right$([NewBarCode],4))="GOOD"));

Also, qryValidate is: 同样,qryValidate是:

SELECT Parts.MaterialID, Validate_UPC([Parts]![Barcode],[Parts]![BarcodeType]) AS NewBarCode,
Parts.BarCodeType, Parts.BarCode
FROM dbo_tblgoods INNER JOIN Parts 
  ON dbo_tblgoods.MaterialID = Parts.MaterialID;

Whenever I got the error "Data type mismatch , I always check those fields I have with expression "=,>.." or Function . Most likely, the cause of the error is a Null field. 每当出现错误"Data type mismatch ,我总是使用表达式“ =,> ..”或Function来检查我拥有的那些字段。最有可能的原因是Null字段。

Try to check your function Validate_UPC([Parts]![Barcode],[Parts]![BarcodeType]) and change it to Validate_UPC(nz([Parts]![Barcode]),nz([Parts]![BarcodeType])) for Null fields. 尝试检查您的函数Validate_UPC([Parts]![Barcode],[Parts]![BarcodeType])并将其更改为Validate_UPC(nz([Parts]![Barcode]),nz([Parts]![BarcodeType]))Null字段。

If it doesn't work, then go check if the parameters in Validate_UPC matches the data type you supplied in your query. 如果不起作用,请检查Validate_UPC中的参数是否与您在查询中提供的数据类型匹配。 eg If you declared Barcode as Integer, a string field is not valid. 例如,如果您将Barcode声明为Integer,则字符串字段无效。 Try to declare the Barcode or BarcodeType as Variant and properly handle them in VBA. 尝试将BarcodeBarcodeType声明为Variant并在VBA中正确处理它们。

Lastly, you are trying to inner join fields on two or more tables that are not of the same data field types. 最后,您尝试在两个或多个表中使用不同数据字段类型的内部联接字段。 I often make this mistake when I create new temporary tables out of data imports(eg excel imports) 当我从数据导入(例如excel导入)创建新的临时表时,经常会犯此错误

I have an excel sheet with 15k data and I realized there were 2 cells which were empty. 我有一个包含15k数据的Excel工作表,我意识到这里有2个单元格是空的。 Therefore, it was giving me this error. 因此,这给了我这个错误。 Thank you all for trying to help me out. 谢谢大家为我提供帮助。

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

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