Wanted to update my login script and incl admin

ct2013

Registered User.
Local time
Today, 18:31
Joined
Jun 6, 2013
Messages
87
Hi there i have the following code i use for my database on startup for users to login.
I wanted to add that if [TxtEmpID]=1 (the administrator) then open form called "admin startup" and all others how i currently have it.

I would be most grateful if someone can help me change the current script as i am having difficulty.

Username - Administartor, pass = 1234
Password - test, pass = 123

Many Thanks

ps. Database attached


Full script below
******************************



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, "Ateres - Login Failed"
Me.USERNAME.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, "Ateres - Login Failed"
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", "[TxtEmpID]=" & Me.cboEmployee.Value) Then

TxtMyEmpID = Me.cboEmployee.Value

'Close logon form and open Startup
DoCmd.OpenForm "Startup"
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "My Current Tasks", acNormal, "", "", , acNormal
If (Forms![My Current Tasks]![Input for] = TempVars!CurrentUserID) Then
DoCmd.Close acForm, "My Current Tasks"
DoCmd.OpenForm "You have current tasks", acNormal, "", "", , acDialog
Else
DoCmd.Close acForm, "My Current Tasks"
DoCmd.Close acForm, "My Current Tasks"
End If


Else
DoCmd.Close acForm, "My Current Tasks"
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Ateres - Login Failure!"
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 your system administrator.", vbCritical, "Restricted Access!"
Application.Quit

End If


End Sub
 

Attachments

Sorry to drive you mad but would it be possible to add that for the admin everything is unlocked e.g. navigation pane, toolbar, design view...
but for regular users all is blocked e.g. navigation pane, toolbar, design views...


If you want to send me your own database with script i would be very happy to transfer that to my database and tweak the code to suit my forms and requirements.

Thanks £1m:):D:o


Ta:cool::p
 

Users who are viewing this thread

Back
Top Bottom