Dim n As Integer
If Text7.Value = "123" And Text9 = "123" Then
DoCmd.OpenForm "主界面窗体", , , stLinkCriteria
Else
MsgBox "密码错误,请重新输入!"
End If
请高手帮忙
密码3次输入错误后退出数据库:
Private Sub cmd登录_Click()
On Error GoTo Err_cmd登陆_Click
If IsNull(Me![用户名]) Then
MsgBox "请输入用户名!", 16, " "
Me![用户名].SetFocus
ElseIf IsNull(Me![密码]) Then
MsgBox "请输入密码!", 16, " "
Me![密码].SetFocus
ElseIf IsNull(DLookup("用户名", "系统用户", "用户名 = '" & Me![用户名] & "'")) Then
MsgBox "此用户不存在!", 16, " "
Me![用户名].SetFocus
ElseIf Me![密码] <> DLookup("密码", "系统用户", "用户名 = '" & Me![用户名] & "'") Then
If m = 3 Then
MsgBox "您3次密码输入错误!系统即将退出!", 16, " "
DoCmd.Quit
ElseIf m = 1 Then
MsgBox "密码错误!3次密码输入错误后将退出系统!" & Chr(10) & "您还有2次机会!", 16, " "
Else
MsgBox "密码错误!您还有" & 3 - m & "次机会!", 16, " "
End If
Me![密码].SetFocus
m = m + 1
Else
UserID = DLookup("用户ID", "系统用户", "用户名 = '" & Me![用户名] & "'")
UserName = Me![用户名]
DoCmd.Close
DoCmd.OpenForm "切换面板"
End If
Exit_cmd登陆_Click:
Exit Sub
Err_cmd登陆_Click:
MsgBox "cmd登陆_Click事件已被取消,发生如下错误:" & Chr(10) & Err.Description, 16, "出错"
Resume Exit_cmd登陆_Click
End Sub