Unload Me
End Sub
Private Sub cmd_ok_Click()
Dim try_times As String
Dim sql As String
Dim rst As ADODB.Recordset
try_times = 0
If (Trim(txt_key.Text) = "") Then
MsgBox "请输入密码", vbOKOnly + vbExclamation, "提示"
Else
sql = "select * from 用户表 where 用户名='" & Trim(cmo_user.Text) & "'"
Set rst = ExecuteSQL(sql, "")
If Trim(rst.Fields(1)) = Trim(txt_key.Text) Then
If Trim(rst.Fields(2)) <> "管理员" Then
frm_main.xitong.Enabled = False '在这里设计非管理员用户的权限,这里我假设让非
管理员用户不能用菜单中的‘系统’
frm_main.shezhi.Enabled = False
frm_main.xinxiweihu.Enabled = False
End If
rst.Close
UserName = Trim(cmo_user.Text)
frm_main.Show
Unload Me
Else
MsgBox "密码不正确,请重新输入", vbOKOnly + vbExclamation, "警告"
txt_key.SetFocus
txt_key.Text = ""
try_times = try_times + 1
Exit Sub '在这里若密码错了应该跳出该过程,否则下面的语句还会执行,这不是你想
要的
End If
'try_times = try_times + 1 '个人认为密码输入错了才加一,你这样的话,用户名错了也会
加一,当然你这里用户名不会错是吧,改得多余了
If try_times = 3 Then
Unload Me
End If
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim sql As String
Dim rst As ADODB.Recordset
sql = "select 用户名 from 用户表 "