Hello Fellow Access Users
So I created a new navigation form and want to limit which tabs are enabled based on security level. So I have a table called tbluser and it has the following fields
userlogin
username
security - Admin or User
What I would like to happen is if they are an admin have 5 extra navigation buttons be available. If they are just a user have the same 5 disabled and if they are not in the list at all then to close the program. Here is what I wrote and I am getting an error "run-time error'2471':
The expression you entered as a query parameter produced this error: '[UserLogin]'
The UserLogin is the username of the computer since we are in a networked environment. The username is actually stored in the tbluser as userlogin. I am not sure if this is playing a part of the problem or not.
<code>
Private Sub Form_Load()
Dim UserLogin As String
Dim userLevel As String
UserLogin = Environ("Username")
Me.user = UserLogin
If IsNull(DLookup("[security]", "tbluser", "[UserLogin] = '" & Me.user & "'")) Then
Else
userLevel = DLookup("[security]", "tbluser", "[UserLogin] = '" & Me.user & "'")
If userLevel = Admin Then
Me.NavigationButton13.Enabled = True
Me.NavigationButton17.Enabled = True
Me.NavigationButton15.Enabled = True
Me.NavigationButton27.Enabled = True
If userLevel = user Then
Me.NavigationButton13.Enabled = False
Me.NavigationButton15.Enabled = False
Me.NavigationButton17.Enabled = False
Me.NavigationButton27.Enabled = False
Else
DoCmd.Quit acQuitSaveAll
End If
End If
End If
End Sub
</code>
So I created a new navigation form and want to limit which tabs are enabled based on security level. So I have a table called tbluser and it has the following fields
userlogin
username
security - Admin or User
What I would like to happen is if they are an admin have 5 extra navigation buttons be available. If they are just a user have the same 5 disabled and if they are not in the list at all then to close the program. Here is what I wrote and I am getting an error "run-time error'2471':
The expression you entered as a query parameter produced this error: '[UserLogin]'
The UserLogin is the username of the computer since we are in a networked environment. The username is actually stored in the tbluser as userlogin. I am not sure if this is playing a part of the problem or not.
<code>
Private Sub Form_Load()
Dim UserLogin As String
Dim userLevel As String
UserLogin = Environ("Username")
Me.user = UserLogin
If IsNull(DLookup("[security]", "tbluser", "[UserLogin] = '" & Me.user & "'")) Then
Else
userLevel = DLookup("[security]", "tbluser", "[UserLogin] = '" & Me.user & "'")
If userLevel = Admin Then
Me.NavigationButton13.Enabled = True
Me.NavigationButton17.Enabled = True
Me.NavigationButton15.Enabled = True
Me.NavigationButton27.Enabled = True
If userLevel = user Then
Me.NavigationButton13.Enabled = False
Me.NavigationButton15.Enabled = False
Me.NavigationButton17.Enabled = False
Me.NavigationButton27.Enabled = False
Else
DoCmd.Quit acQuitSaveAll
End If
End If
End If
End Sub
</code>
Last edited: