求个access 的密码登录窗体代码用VBA实现的那种

如题所述

第1个回答  2006-12-29
Private Sub Cmd确定_Click()
On Error GoTo Err_Cmd确定_Click
Dim mypasswords As String
Dim jishu As Integer
jishu = jishu + 1

If jishu < 3 Then
mypasswords = DLookup("password", "用户密码", "[username]=" & "'" & Me!用户名 & "'")
If IsNull(Me.密码) = False And Me.密码 = mypasswords Then
Me.Visible = False
DoCmd.Close acForm, "登陆背景", acSaveYes
If Me!用户名 = "管理员" Then
DoCmd.OpenForm "考勤管理系统", acNormal, , , acFormReadOnly, acWindowNormal
Else
DoCmd.OpenForm "员工查询系统", acNormal, , , acFormReadOnly, acWindowNormal
End If
Else

MsgBox "用户名和密码错误,请仔细确认", , "请重新输入"

Me.密码.SetFocus

End If
Else
MsgBox "已经试过三次,将要退出,如想进入请与管理员联系!"
Quit
End If
Exit_Cmd确定_Click:
Exit Sub

Err_Cmd确定_Click:
MsgBox "请输入用户名和密码,工作时请不要如此大意"
Resume Exit_Cmd确定_Click

End Sub

这是我去年做的用的代码本回答被提问者采纳
相似回答