Hi there I am kind of new to access, but i have worked with VB.net before and SQL so this VBA Language is Similar, BUT! I am stuck with something and it is wrecking my brain.
What is happening is that when the 'User' Enters username and password, they are correct, otherwise it will show an error, but it will not open the "Switchboard" to the user's access level i.e Customer or Admin the login form just sits there and does nothing.
The Ok button handles the user login and then checks the user's access level from there it Should open the next form and close itself but it does not.
P.S I was working on this today and realised that emails would double up so that is not a efficient way to login so im half way through changing to username, all the search queries with the username criteria work just the msg boxes haven't changed yet
Here Is My Code:
Code:
Private Sub Command1_Click()
Dim userlevel As Boolean
Dim Adminlevel As Boolean
userlevel = False
Adminlevel = False
If IsNull(Me.email1) Then
MsgBox "Please Enter Your Email", vbInformation, "Email Required"
Me.email1.SetFocus
ElseIf IsNull(Me.password1) Then
MsgBox "Please Enter Password", vbInformation, "Password Required"
Me.password1.SetFocus
Else
If (IsNull(DLookup("[Username]", "Participants", "[Username] ='" & Me.email1.Value & "' and Password = '" & Me.password1.Value & "'"))) Then
MsgBox "Incorrect Email Or Password"
Else
If DLookup("[Username]", "Participants", "[Username] ='" & Me.email1.Value & "' and [Usrlvl] ='" & User & "'") Then
userlevel = True
Adminlevel = False
End If
If DLookup("[Username]", "Participants", "[Username] ='" & Me.email1.Value & "' and [Usrlvl] ='" & Admin & "'") Then
userlevel = False
Adminlevel = True
End If
If Adminlevel = True Then
DoCmd.Close acForm, Me.Name, acSaveNo
DoCmd.OpenForm "Admin_Switchboard", acNormal
ElseIf userlevel = True Then
DoCmd.Close acForm, Me.Name, acSaveNo
DoCmd.OpenForm "Switchboard user", acNormal
End If
End If
End If
End Sub