Dim stDocName As String
Dim stLinkCriteria As String
If IsNull(user) Then
MsgBox "请选择登录用户!", vbCritical, "提示"
Exit Sub
ElseIf IsNull(password) Then
MsgBox "密码不能为空,请重新输入!", 64, "提示"
Me.password.SetFocus
Exit Sub
End If
Set rsX = CurrentDb.OpenRecordset("select * from [yhb] where [用户名]='" & user & "' and [密码]='" & password & "'")
If Not rsX.EOF Then
user_level = level
login_successful = 1
user_name = user
rsX.Close
Me.Visible = False '隐藏窗体
stDocName = "主控制面板" '打开主控制面板
Cmd.OpenForm stDocName, , , stLinkCriteria
Else
If I < 2 Then
MsgBox "用户名或密码错误,请重新输入!您还可以输入" & 2 - I & "次密码。", 16, "提示"
password.SetFocus
password = Null
I = I + 1
rsX.Close
Else
MsgBox "您已经连续3次输入错误密码,系统马上关闭!", 16, "提示"
DoCmd.Close acForm, Me.Name
DoCmd.Quit
End If
End If
End Sub