打家看看这段程序有什么错误啊?急等,谢谢哥哥姐姐们了!
程序在执行的过程当中,If mrc.EOF = True Then,这句代码被高亮显示了,出现提示“ 实时错误‘91’对象变量或with块变量未设置。这个怎么办啊?着急的我。谢谢好心人了!
Private Sub cmdok_Click()
Dim txtsql As String '用于存放SQL语句
Dim mrc As ADODB.Recordset '存放记录集对象
Dim msgtext As String '存放返回的信息
' Dim username As String
username = " "
password = " "
If Trim(txtusername.Text = " ") Then
MsgBox "没有这个用户,请重新输入用户名! ", vbOKOnly + vbExclamation, "警告 "
txtusername.SetFocus
Else
txtsql = "select * from users where user_id= ' " & Trim(txtusername.Text) & " ' "
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名! ", vbOKOnly + vbExclamation, "警告 "
txtusername.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
username = Trim(txtusername.Text)
password = Trim(txtPassword.Text)
Else
MsgBox "输入密码不正确,请重新输入! ", vbOKOnly + vbExclamation, "警告 "
txtPassword.SetFocus
txtPassword.Text = " "
End If
End If
End If
End Sub
[解决办法]
把 ExecuteSQL 这个函数贴出来看一来,可能这个函数的返回值不是记录集吧。