Access complains "Data Type Mismatch in criteria expression" with this code ...
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.
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.
you have to add the quotes to the txt object. So: "[Serial Number] ='" & Val(txtSERIAL) & "'")) > 1
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.