Open specific form based on return from SQL statement
I'm trying to get some code put together, so a specific form will open, based on a users 'AccessLevel'. However it won't work.
This is the code I have so far:
Thanks.
I'm trying to get some code put together, so a specific form will open, based on a users 'AccessLevel'. However it won't work.
This is the code I have so far:
Code:
Private Sub Form_Timer()
Dim strSecurityLevel As String
Dim LID As Variant
LID = GetUser() 'this get users loginID
strSecurityLevel = "SELECT tblUserDetails.SecurityLevel from tblUserDetails WHERE LoginID = '" & LID & "'"
If strSecurityLevel = 4 Then
DoCmd.Close
DoCmd.OpenForm "frmSecurity_4"
ElseIf strSecurityLevel = 3 Then
DoCmd.Close
DoCmd.OpenForm "frmSecurity_3"
ElseIf strSecurityLevel = 2 Then
DoCmd.Close
DoCmd.OpenForm "frmSecurity_2"
Else
DoCmd.Close
DoCmd.OpenForm "frmSecurity_1"
End If
End Sub
Thanks.
Last edited: