Private Sub cmdLogin_Click()
On Error GoTo ERR_CmdLOGIN_CLICK
Dim rs As New ADODB.Recordset
Dim str As String
Dim num As Integer
str = "select COUNT(Person.ID) from Person where Person.ID='" & Me.userName
str = str & "'and Person.PassWord='" & Me.PASSWORD & "'"
Set rs = getrs(str)
num = rs(0)
If IsNull(Me.userName) Then
MsgBox ("请输入用户姓名!")
ElseIf IsNull(Me.PASSWORD) Then
MsgBox ("请输入用户密码!")
ElseIf num <> 1 Then
MsgBox ("没有这个用户,或者密码错误!")
Me.userName = ""
Me.PASSWORD = ""
Me.userName.SetFocus
Exit Sub
Else
Me.Visible = False
DoCmd.OpenForm "人事管理系统主窗体"
End If
EXIT_CMDLOGIN_CLICK:
Exit Sub
ERR_CmdLOGIN_CLICK:
MsgBox (Err.Description)
Resume EXIT_CMDLOGIN_CLICK
End Sub
Private Sub FORM_LOAD()
Me.USENAME.SetFocus
Me.userName = ""
Me.PASSWORD = ""
End Sub