Good Day!
I currently have an application that I've created for a work unit. Users must log in using a username and password that has been setup as part of the application.
What I would like to do (if possible) is send each different user to a default form based on their specific job function. Below is the logon script currently in place within this app:
Private Sub cmdLogOn_Click()
On Error GoTo Err_cmdLogOn_Click
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblUserDetails", dbOpenDynaset)
If IsNull(Me.txtUserName) Then
PopUpMsgBox Message1, 2, Title1, vbCritical
Me.txtUserName.SetFocus
Call CheckLogAttempts
ElseIf IsNull(Me.txtPassword) Then
PopUpMsgBox Message1, 2, Title1, vbCritical
Me.txtPassword.SetFocus
Call CheckLogAttempts
ElseIf Me.txtPassword = "XXXXXXXX" Then 'Admin Password
DoCmd.OpenForm "frmMain"
User.UserLevel = 1
ElseIf Me.txtPassword = "YYYYYYYY" Then 'Emergency Password
DoCmd.OpenForm "frmUserDetails"
Else
User.Password = PerformEncryption(Me.txtPassword, True)
rst.FindFirst "Password = '" & User.Password & "'" & " And UserName = '" & Me.txtUserName & "'"
If rst.NoMatch Then
Call ErrorMessage
Else
If PerformEncryption(Me.txtPassword, True) = User.Password Then
With User
.UserName = Me.txtUserName
.UserLevel = rst.Fields("UserLevelID")
.UserID = rst.Fields("UserID")
.Active = rst.Fields("Active")
End With
rst.Close
If User.Active = False Then
MsgBox " Your User account has been suspended. " & Chr(13) & "Please contact your System Administrator " & Chr(13) & " to have your account reset.", vbExclamation, " Log On Error"
Me.txtPassword = ""
Me.txtUserName = ""
Me.txtUserName.SetFocus
User.Password = ""
Else
DoCmd.OpenForm "frmMain"
Call fLogUser(1)
DoCmd.Close acForm, Me.Name
End If
Else
Call ErrorMessage
End If
End If
End If
Exit_cmdLogOn_Click:
Exit Sub
Err_cmdLogOn_Click:
Select Case Err.Number
Case 94
Call ErrorMessage
Resume Exit_cmdLogOn_Click
Case Else
MsgBox Err.Description, vbCritical, " Log On Error"
Resume Exit_cmdLogOn_Click
End Select
End Sub
What I would like to do now is send the user (on successful login) to the default form that is stipulated within the DefaultForm field of the tblUserDetails table. If no default form is stipulated in the DefaultForm field, they get sent to the frmMain Form.
Any ideas??