'方法一=============================================================================
'Private Sub DL_Click()
'If YHM <> "" And mm <> "" Then
' If Me.mm = DLookup("password", "User_information", "user='" & Me.YHM & "'") Then
' MsgBox "登录成功"
' DoCmd.Close acForm, Me.Name
' DoCmd.OpenForm "home", acNormal
' Else
' MsgBox "账号或密码错误,请重新输入"
' End If
'Else
'MsgBox "请输入账号和密码"
'End If
'End Sub
'方法二==============================================================================
Private Sub DL_Click()
Dim db1 As DAO.Database
Dim rs1 As DAO.Recordset
Set db1 = CurrentDb()
Dim SQL_str1 As String
SQL_str1 = "select user,password,mmsd,mmcz from User_information where user='" & YHM & "'"
Set rs1 = db1.OpenRecordset(SQL_str1, dbOpenDynaset)
If Me!YHM = Null Then
MsgBox "用户名不能为空"
YHM.SetFocus
Exit Sub
ElseIf Me!MM = Null Then
MsgBox "请用户密码不能为空"
MM.SetFocus
Exit Sub
ElseIf rs1.EOF = True Then
MsgBox "账户不存在!"
Exit Sub
Else
rs1.MoveFirst
If rs1.Fields(1) = MM Then
userid = Me!YHM
If 1 = rs1!mmsd Then
MsgBox "此账户已被锁定!请联系管理员解锁"
Exit Sub
ElseIf 1 = rs1!mmcz Then
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Password_reset", acNormal
Exit Sub
Else
MsgBox "登录成功"
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Home", acNormal
End If
Else
If i < 2 Then
i = i + 1
MsgBox "密码不正确!你还有" & 3 - i & "次机会"
Else
MsgBox "密码输入错误3次,已锁定!请联系管理员解锁"
rs1.Edit
rs1!mmsd = 1
rs1.Update
Exit Sub
End If
End If
End If
rs1.Close
Set rs1 = Nothing
db1.Close
Set sb1 = Nothing
Exit Sub
End Sub
Private Sub Form_Load()
Me!YHM.SetFocus
'Me!YHM.Value = userhc
End Sub