matthewnsarah07
Registered User.
- Local time
- Today, 08:59
- Joined
- Feb 19, 2008
- Messages
- 192
I am using a basic logon form on my database which checks the username and password. Originally it then took all users to one screen, I have added in a SelectCase statement in order to try and direct users to their own form but whatever user I put in it still sends them to the old splash screen.
I have attached the code below, can anyone spot where I have gone wrong - Combo12(unbound) is the box in the form where the username comes from and this is linked the tblemployees for the values.
Thanks for your help
Matt
I have attached the code below, can anyone spot where I have gone wrong - Combo12(unbound) is the box in the form where the username comes from and this is linked the tblemployees for the values.
Thanks for your help
Matt
PHP:
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.Combo12) Or Me.Combo12 = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.Combo12.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.Combo12.Value) Then
lngMyEmpID = Me.Combo12.Value
Select Case [Combo12].Value
Case "User1"
DoCmd.OpenForm "User1"
Case "User2"
DoCmd.OpenForm "User2"
Case "User3"
DoCmd.OpenForm "User3"
Case Else
DoCmd.OpenForm "frmSplash_Screen"
End Select
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 your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub