简体   繁体   English

IF语句使用Dcount

[英]IF statement using Dcount

Access complains "Data Type Mismatch in criteria expression" with this code ... Access抱怨此代码“标准表达式中的数据类型不匹配” ...

If DCount("[Serial Number]", "INVENTORY OVERVIEW", "[Serial Number] =" & Val(txtSERIAL)) > 1 Then

Serial Number is the field I'm trying to count. 序列号是我要计算的字段。 INVENTORY OVERVIEW is the table where I am trying to do the count. 库存概述是我要计算的表格。 txtSerial is the text box on a userform. txtSerial是用户窗体上的文本框。

The objective of this if statement is to determine if there are more than one of the same serial number, and report to the user when they submit a new entry if that serial number already exists within the recordset. 该if语句的目的是确定同一序列号中是否存在多个序列号,如果记录集中已存在该序列号,则在用户提交新条目时向用户报告。

you have to add the quotes to the txt object. 您必须将引号添加到txt对象。 So: "[Serial Number] ='" & Val(txtSERIAL) & "'")) > 1 因此:“ [[序列号] ='“&Val(txtSERIAL)&”'“)))> 1

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

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