我的问题是,无论我在文本框中输入什么内容,它都只会执行MsgBox ("Estimate No" & editform.edittext.Value & " is found")
,即使数据库中不存在该记录。它应该执行代码
在数据库中找不到记录时MsgBox ("Unable to find '" & editform.edittext.Value & "'")
。
If editform.OptionButton1.Value = True Then
strConnectStr = "something"
Qry = "SELECT * " & _
"FROM test.dbo.estimateRegister " & _
"WHERE test.dbo.estimateRegister.estimateNo = '" & edittext.Text & "%'"
cnt.Open strConnectStr
rst.Open Qry, cnt
If Not rst.EOF Then
MsgBox ("Estimate No" & editform.edittext.Value & " is found")
Unload Me
UserForm2.Show
Else
MsgBox ("Unable to find '" & editform.edittext.Value & "'")
End If
End If
答案 0 :(得分:0)
尝试替换此行:
If Not rst.EOF Then
这一行
If rst.RecordCount <> 0 Then