Option Compare Database
Option Explicit
Private Sub Form_Current()
End Sub
Private Sub Form_Load()
Dim check As AcCommand
On Error GoTo Form_Open_Err
DoCmd.SelectObject acForm, "主切换面板", True
DoCmd.Minimize
check = False
Form_Open_Exit:
Exit Sub
Form_Open_Err:
MsgBox Err.Description
Resume Form_Open_Exit
End Sub
Private Sub 登录_Click()
On Error GoTo Err_登录_Click
Dim strSQL As String
Dim rs As New ADODB.Recordset
If IsNull(Me.用户名) Or Me.用户名 = "" Then
DoCmd.Beep
MsgBox ("请输入用户名")
ElseIf IsNull(Me.密码) Or Me.密码 = "" Then
DoCmd.Beep
MsgBox ("请输入密码")
Else
strSQL = "SELECT * FROM 管理员 WHERE 用户名 ='" & Me.用户名 & "'and 密码='" & Me.密码 & "'"
Set rs = GetRs(strSQL)
If rs.EOF Then
DoCmd.Beep
MsgBox ("用户名或密码错误")
Me.用户名 = ""
Me.密码 = ""
Me.用户名.SetFocus
Exit Sub
Else
DoCmd.Close
check = True
DoCmd.OpenForm ("主切换面板")
End If
End If
Set rs = Nothing
Exit_登录_Click:
Exit Sub
Err_登录_Click:
MsgBox (Err.Description)
Debug.Print Err.Description
Resume Exit_登录_Click
End Sub
Private Sub 取消_Click()
Dim check As AcCommand
check = False
DoCmd.Close
End Sub