Hi there,
I have adapted a piece of code to allow users to login into the database. I have two types of users, that of student and that of admin. If the admin logs in I want them to be taken to a different form than ordinary users.
Here is the code i have so far
Any help would be much appreciated
Ross
I have adapted a piece of code to allow users to login into the database. I have two types of users, that of student and that of admin. If the admin logs in I want them to be taken to a different form than ordinary users.
Here is the code i have so far
Code:
Private Sub Login_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboUser) Or Me.cboUser = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboUser.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 tblUsers to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("Password", "Users", "[UserID]=" & Me.cboUser.Value) Then
UserID = Me.cboUser.Value
[I] If Me.cboUser = AdminID Then
DoCmd.OpenForm "AdminForm"
Else
DoCmd.OpenForm "Studentform"
End If[/I] - My attempt at trying to get them to go to different forms!
'Close logon form and open splash screen
'DoCmd.Close acForm, "frmLogn", acSaveNo
'DoCmd.OpenForm "Questions" [I] Just a test to see if it would open a form[/I]
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
Any help would be much appreciated
Ross