Hi,
I have been playing around with some Access tutorials on the Internet, am interested in how I would go about changing a User Login to also have enabled and disabled accounts.
Here is the site; http://www.databasedev.co.uk/login.html
On the cmdLogin button I have added the following code;
Here is the main cmdLogin code;
Also on the table I have added chkAccStatus, which is Yes/No data type.
Thanks for any pointers...
I have been playing around with some Access tutorials on the Internet, am interested in how I would go about changing a User Login to also have enabled and disabled accounts.
Here is the site; http://www.databasedev.co.uk/login.html
On the cmdLogin button I have added the following code;
Code:
If (chkAccStatus) = False Then
MsgBox "Your account is disabled see admin.", vbOKOnly, "Disabled Account"
Exit Sub
End If
Code:
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
"[lngEmpID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "frmSplash_Screen"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Thanks for any pointers...