请高手帮忙看一下,纠错!
登录窗体,利用adodc控件从access数据库的“用户管理”表检查用户名称和登录密码,两个文本名是txtUserName和txtPassword运行过程有问题,请大家纠错,谢谢!Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
If Trim(txtUserName.Text) = "" Then
MsgBox "用户名不能为空", vbExclamation + vbOKOnly, "提醒"
txtUserName.SetFocus
Exit Sub
End If
If Trim(txtPassword.Text) = "" Then
MsgBox "用户密码不能为空", vbOKOnly, "提醒"
txtPassword.SetFocus
Exit Sub
End If
If Not IsNumeric(txtPassword.Text) Then
MsgBox "密码必须为数字", vbExclamation + vbOKOnly, "提醒"
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword)
txtPassword.SetFocus
Exit Sub
End If
Adodc1.RecordSource = "select * from 用户管理 where 用户名称= '" & txtUserName.Text & "'"
Adodc1.Refresh
With Adodc1.Recordset
If txtUserName.Text <> Adodc1.Recordset.Fields("用户名称").Value Then
MsgBox "用户名错误,请重新输入"
txtUserName.SetFocus
Exit Sub
ElseIf txtPassword.Text <> Adodc1.Recordset.Fields("登录密码").Value Then
MsgBox "密码错误,请重新输入"
txtPassword.SetFocus
Exit Sub
Else
MDIForm1.Show
End If
End With
Exit Sub
End Sub