对象变量或whit变量不存在
Private Sub cmdOK_Click()Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
'变量定义 txtSQL是用来存放SQL语句,MsgText存放返回信息
UserName = ""
If Trim(txtUserName.Text = "") Then
'判断用户名输入是否为空
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
txtSQL = "select * from Manager where username = '" & 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)
'记录用户名和密码到全局变量
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If
miCount = miCount + 1
If miCount = 3 Then
'记录密码输入的次数,累计到3此则自动结束程序
Me.Hide
End If
Exit Sub
End Sub