实时错误 '3021' eof或eof 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录
当我运行程序时,就会显示 实时错误 '3021' eof或eof 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录
源代码如下:
Private Sub cmdOK_Click()
Dim txtSQL As String
Dim MsgText As String
Dim mrc As ADODB.Recordset
If Trim(Text1(0).Text) <> Trim(Text1(1).Text) Then
MsgBox "两次输入的密码不一样!", vbOKOnly + vbExclamation, "警告"
Text1(0).SetFocus
Text1(0).Text = ""
Text1(1).Text = ""
Else
txtSQL = "select*from user_info where user_ID ='" & UserName & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.Fields(1) = Text1(1).Text
mrc.Update
mrc.Close
MsgBox "密码修改成功!", vbOKOnly + vbExclamation, "警告"
Me.Hide
End If
End Sub
[最优解释]
txtSQL = "select * from user_info where user_ID ='" & UserName & "'"
if mrc.recordcount>0 then
mrc.Fields(1) = Text1(1).Text
....
end if
[其他解释]
mrc.recordcount =0 没有查询到数据
[其他解释]