vb 运行程序提示是对象变量或with块变量未设置,请问我怎么解决.
Public OK As BooleanDim rs As Recordset
Dim sql As String
Dim msgtxt As String
Private Sub cmdOk_Click()
UserName = ""
If Trim(txtUserName.Text = "") Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
sql = "select * from userpwd where U_name = " & "'" & txtUserName.Text & "'"
Set rs = ExecuteSQL(sql, msgtxt)
If rs.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
rs.Open sqlstr, Conn, adOpenStatic, adLockReadOnly
Else
If Trim(rs.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
UserName = Trim(txtUserName.Text)
UserPass = Trim(txtPassword.Text)
rs.Close
Me.Hide
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If
End Sub
Private Sub cmdCancel_Click()
OK = False
Me.Hide
End
End Sub
Private Sub Form_Activate()
txtUserName.SetFocus
End Sub