不用这样判断是否存在,这种代码是很低效的
这样判断
dim rst as recordset
'假定 借书证ID 为一个字符串字段
set rst=currentdb.openrecordset("select 借书证ID from 借书证档案 where 借书证ID='" & me.借书证ID & "'" )
if nz(rst.借书证ID,"")="" then
msgbox "已经存在"
exit sub
end if
rst.close
set rst=nothing
目测没有错,你debug看看,rs.recordcount 是多少