I have been trying to get this to work all day it seems. Not sure what I am doing wrong.
I have a table [Employee List]. In that table I have [Employee Name] and their [Role] as fields.
Role has either Admin or User as options.
On the login form, I have a Combo box with their name, which they select based on [Employee List]. No password or anything. Real simple.
This sets a TempVar of [CurrentUserID] which I use to auto populate a form with. That part works fine.
What I want to do is show a button on the main form [Dashboard] based on that user's role. Specifically, I want to show it if they are admin.
This is what I have:
Any idea what I am doing wrong? Lol.
I have a table [Employee List]. In that table I have [Employee Name] and their [Role] as fields.
Role has either Admin or User as options.
On the login form, I have a Combo box with their name, which they select based on [Employee List]. No password or anything. Real simple.
This sets a TempVar of [CurrentUserID] which I use to auto populate a form with. That part works fine.
What I want to do is show a button on the main form [Dashboard] based on that user's role. Specifically, I want to show it if they are admin.
This is what I have:
Code:
Private Sub Form_Open(Cancel As Integer)
UserLevel = DLookup("[Role]", "[Employee List]", "[Employee Name]='" & [TempVars]![CurrentUserID] & "'")
If UserLevel = "Admin" Then
Me.Adminbtn.Visible = True
Else
Me.Adminbtn.Visible = False
End If
End Sub
Any idea what I am doing wrong? Lol.