J
Joker via AccessMonster.com
Hello,
I have set up thru VBA my own security but I'm running into a little problem
with a update I'm trying to make. Previously I had it opening one form if
your authorized to go into the database and had the correct password but now
I'm going to need to have a case statement (or something similar) depending
the the users security level if they get the read only form or if they get
they data entry form. Any ideas on what I can do to correct this would be
greatly appreciated. Below is my code that works.
Private Sub cmdLogin_Click()
Dim rsUser2 As Recordset
'authenticate user, obtain access level and department
On Error GoTo cmdLogin_Click_Error
If AuthenticateUser <> True Then
MsgBox "Unable to log in. Please try again."
Me![cboUser] = Null
Me![txtPassword] = Null
Me![cboUser].SetFocus
Else
Call DetermineAccess
'---------------------------------------------------------
' THIS DECIDES WHAT FORM YOU'RE ABLE TO VIEW
'---------------------------------------------------------
DoCmd.OpenForm "frm_Main", acNormal
Me.Visible = False
End If
On Error GoTo 0
Exit Sub
cmdLogin_Click_Error:
End Sub
~~~~~~~This is my most recent update trial~~~~~~~
Private Sub cmdLogin_Click()
Dim rsUser2 As Recordset
Dim strSql2 As String
'authenticate user, obtain access level and department
On Error GoTo cmdLogin_Click_Error
If AuthenticateUser <> True Then
MsgBox "Unable to log in. Please try again."
Me![cboUser] = Null
Me![txtPassword] = Null
Me![cboUser].SetFocus
Else
Call DetermineAccess
'---------------------------------------------------------
' THIS DECIDES WHAT FORM YOU'RE ABLE TO VIEW
'---------------------------------------------------------
strSql2 = ""
strSql2 = strSql2 & "SELECT Analyst.* FROM Analyst "
strSql2 = strSql2 & "Where Analyst.GID ='" & Environ("username") & "';"
Set rsUser2 = CurrentDb.OpenRecordset(strSql2)
If rsUser2.BOF = True And rsUser2.EOF = True Then
'user not found in table... close the database
Set rsUser2 = Nothing
Select Case rsUser2.Fields("User_Access_Level").Value
Case Is = 1
DoCmd.OpenForm "frm_Main", acNormal
Case Is = 2
DoCmd.OpenForm "frm_Main", acNormal
Case Is = 3
DoCmd.OpenForm "frm_MainReadOnly", acNormal
End Select
Me.Visible = False
End If
' DoCmd.OpenForm "frm_Main", acNormal
' Me.Visible = False
End If
On Error GoTo 0
Exit Sub
Form_Load_Exit:
Exit Sub
cmdLogin_Click_Error:
Errorhandler:
MsgBox Err.Number & ", " & Err.Description & ", frmUser_Login.Form_Load."
Resume Form_Load_Exit
End Sub
I have set up thru VBA my own security but I'm running into a little problem
with a update I'm trying to make. Previously I had it opening one form if
your authorized to go into the database and had the correct password but now
I'm going to need to have a case statement (or something similar) depending
the the users security level if they get the read only form or if they get
they data entry form. Any ideas on what I can do to correct this would be
greatly appreciated. Below is my code that works.
Private Sub cmdLogin_Click()
Dim rsUser2 As Recordset
'authenticate user, obtain access level and department
On Error GoTo cmdLogin_Click_Error
If AuthenticateUser <> True Then
MsgBox "Unable to log in. Please try again."
Me![cboUser] = Null
Me![txtPassword] = Null
Me![cboUser].SetFocus
Else
Call DetermineAccess
'---------------------------------------------------------
' THIS DECIDES WHAT FORM YOU'RE ABLE TO VIEW
'---------------------------------------------------------
DoCmd.OpenForm "frm_Main", acNormal
Me.Visible = False
End If
On Error GoTo 0
Exit Sub
cmdLogin_Click_Error:
End Sub
~~~~~~~This is my most recent update trial~~~~~~~
Private Sub cmdLogin_Click()
Dim rsUser2 As Recordset
Dim strSql2 As String
'authenticate user, obtain access level and department
On Error GoTo cmdLogin_Click_Error
If AuthenticateUser <> True Then
MsgBox "Unable to log in. Please try again."
Me![cboUser] = Null
Me![txtPassword] = Null
Me![cboUser].SetFocus
Else
Call DetermineAccess
'---------------------------------------------------------
' THIS DECIDES WHAT FORM YOU'RE ABLE TO VIEW
'---------------------------------------------------------
strSql2 = ""
strSql2 = strSql2 & "SELECT Analyst.* FROM Analyst "
strSql2 = strSql2 & "Where Analyst.GID ='" & Environ("username") & "';"
Set rsUser2 = CurrentDb.OpenRecordset(strSql2)
If rsUser2.BOF = True And rsUser2.EOF = True Then
'user not found in table... close the database
Set rsUser2 = Nothing
Select Case rsUser2.Fields("User_Access_Level").Value
Case Is = 1
DoCmd.OpenForm "frm_Main", acNormal
Case Is = 2
DoCmd.OpenForm "frm_Main", acNormal
Case Is = 3
DoCmd.OpenForm "frm_MainReadOnly", acNormal
End Select
Me.Visible = False
End If
' DoCmd.OpenForm "frm_Main", acNormal
' Me.Visible = False
End If
On Error GoTo 0
Exit Sub
Form_Load_Exit:
Exit Sub
cmdLogin_Click_Error:
Errorhandler:
MsgBox Err.Number & ", " & Err.Description & ", frmUser_Login.Form_Load."
Resume Form_Load_Exit
End Sub