主题:大家快帮帮我吧,我已经在电脑前坐了一晚上了,这个问题该怎么解决呢,郁闷死了
Private Sub cmdok_Click()
Dim txtsql As String
Dim mrc As ADODB.Recordset
Dim msgtext As String
'变量定义,txtsql是用来存放SQL 语句msgtext存放返回信息
username = ""
If txtusername.Text = "" Then
'判断用户名是否为空
MsgBox "用户名不能为空", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
Else
txtsql = "select *from guanli where 用户名='" & txtusername.Text & "'"
'对所输入用户名进行查询
Set mrc = executesql(txtsql, msgtext)
'msgbox msgtext
[color=FF0000]If mrc.EOF = True Then[/color]
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
Else
If Trim(mrc.Fields("密码")) = Trim(txtpassword.Text) Then
'判断密码是否正确
ok = True
level = mrc.Fields("用户级别")
'获取用户级别
mrc.Close
Me.Hide
frmmain.Show
username = txtusername.Text
pwd = txtpassword.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
现在运行以后就报错:对象变量或with块变量未设置
Dim txtsql As String
Dim mrc As ADODB.Recordset
Dim msgtext As String
'变量定义,txtsql是用来存放SQL 语句msgtext存放返回信息
username = ""
If txtusername.Text = "" Then
'判断用户名是否为空
MsgBox "用户名不能为空", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
Else
txtsql = "select *from guanli where 用户名='" & txtusername.Text & "'"
'对所输入用户名进行查询
Set mrc = executesql(txtsql, msgtext)
'msgbox msgtext
[color=FF0000]If mrc.EOF = True Then[/color]
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
Else
If Trim(mrc.Fields("密码")) = Trim(txtpassword.Text) Then
'判断密码是否正确
ok = True
level = mrc.Fields("用户级别")
'获取用户级别
mrc.Close
Me.Hide
frmmain.Show
username = txtusername.Text
pwd = txtpassword.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
现在运行以后就报错:对象变量或with块变量未设置