mtagliaferri
Registered User.
- Local time
- Today, 23:52
- Joined
- Jul 16, 2006
- Messages
- 550
I have the following code which is not working as it should...
all users work in different department (currently 3: IBM, OPS and ADM) these values are set in the tblUser under Department depending in which department the user is it will open the appropriate Main Form, Unfortunately it is not working in full, first because I am stuck with the Else option to allow more than 2 options (Currently 3 but the departments might be more)!
all users work in different department (currently 3: IBM, OPS and ADM) these values are set in the tblUser under Department depending in which department the user is it will open the appropriate Main Form, Unfortunately it is not working in full, first because I am stuck with the Else option to allow more than 2 options (Currently 3 but the departments might be more)!

Code:
Private Sub cmdLogin_Click()
Dim UserLevel As String
If IsNull(Me.txtUsername) Then
MsgBox "Enter Username", vbInformation, "Username Required"
Me.txtUsername.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Enter Password", vbInformation, "Password Required"
Me.txtPassword.SetFocus
Else
If (IsNull(DLookup("Username", "tblUser", "Username ='" & Me.txtUsername.Value & "'"))) Or _
(IsNull(DLookup("Password", "tblUser", "Password='" & Me.txtPassword.Value & "'"))) Then
MsgBox "Incorrect Username or Password"
Else
UserLevel = DLookup("Department", "tblUser", "Username ='" & Me.txtUsername.Value & "'")
DoCmd.Close
If UserLevel = IBM Then
DoCmd.OpenForm "frmMainIBM"
Else
DoCmd.OpenForm "frmMainOPS"
End If
End If
End If
End Sub