Mình có Form Login
Đã có 1 bảng:
mã code:
-------------------
Option Compare Database
Private intLogonAttempts As Integer
Private Sub cboEmployee_NotInList(NewData As String, Response As Integer)
MsgBox "Ban phai nhap dung 'User name' cua ban.", vbInformation, Me.Caption
Response = acDataErrContinue
End Sub
Private Sub cmdCancel_Click()
On Error GoTo Err_cmdCancel_Click
DoCmd.Quit
Exit_cmdCancel_Click:
Exit Sub
Err_cmdCancel_Click:
MsgBox Err.Description
Resume Exit_cmdCancel_Click
End Sub
Private Sub cmdLogin_Exit(Cancel As Integer)
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.cboEmployee.SetFocus
End Sub
Private Sub cboEmployee_AfterUpdate()
txtstrAccess = DLookup("strAccess", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value)
Me!txtUserName = Me!cboEmployee.Column(1)
Me.txtPassword.SetFocus
End Sub
Private Sub cmdLogin_Click()
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "Ban phai chon 'User Name' cua ban.", vbCritical, "User name"
Me.cboEmployee.SetFocus
Exit Sub
End If
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "Ban phai nhap mat khau cua ban vao o 'Password'.", vbCritical, "Nhap mat khau"
Me.txtPassword.SetFocus
Exit Sub
End If
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
MsgBox "Ban da dang nhap thanh cong...", vbOKOnly, "Dang nhap..."
DoCmd.Close
DoCmd.OpenForm "frmadmin"
Me.Visible = False
Else
MsgBox "Mat khau khong dung. Vui long nhap lai.", vbExclamation, "Sai mat khau!"
Me.txtPassword.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 2 Then
MsgBox "Mat khau khong dung, chuong trinh se thoat. Vui long lien he voi Admin.", vbCritical, "Mat khau!"
Application.Quit
End If
End Sub
-----
Để bấm OK về frmadmin chương trình thì ko về được >> HELP