|
给你看看我的登录窗体代码,大家一起学习个:
Private Sub CMD_登录_Click()
Dim nStatue As Integer
in_ta = False
Set b = CurrentDb.OpenRecordset("用户名表")
If Me![用户名称] = "Admin" And Me![用户密码] = "Admin" Then
in_ta = True
GoTo Open_用户管理 Else
Do Until b.EOF
If Me![用户名称] = b("用户名称") And Me![用户密码] = b("用户密码") Then
in_ta = True
cUser = b("用户名称")
nStatue = b("用户状态")
If nStatue <> 0 Then
MsgBox cUser & " 帐号己被停用,请资询相关管理人员", vbOKOnly, "系统提示"
Call Cmd_退出_Click
Else
GoTo Open_用户管理
End If
End If
b.MoveNext
Loop
i = i + 1
If i = 3 Then
MsgBox "登录验证错误己达三次,程式即将结束", vbOKOnly, "错误提示"
'Set b = Nothing
Application.Quit
End If
MsgBox "登录验证错误,请重新确认用户帐号及密码", vbOKOnly, "登录提示"
in_ta = False
Me![用户名称] = ""
Me![用户密码] = ""
Me![用户名称].SetFocus
Exit Sub
End If
Open_用户管理:
Me.Visible = False
DoCmd.OpenForm "用户管理"
End Sub |
|