Reputation: 531
I have created a couple of functions to determine the permission level of a user in MS Access. I have a table called tblEmployees that contains the following fields: (FirstName, LastName, Email, Role, Login, PermissionLevel).
I have created this function to determine the "Login" (this works fine every time):
Option Compare Database Public intPermissionLevel As Integer
Public Function getUserName() As String
getUserName = Environ("USERNAME")
End Function
I have then created this function to lookup the permission level using the value supplied for the "Login" field by the getUserName function above. The correct value is passed into the "LookupPermissionLevel" function, however I am getting the following error every time. (ct627 is my username and it is included in the tblEmployees)
"The expression that you entered as a query parameter produced this error: 'ct627'"
Public Function LookUpPermissionLevel(getUserName As String) As Integer
intPermissionLevel = DLookup("PermissionLevel", "tblEmployees", "Login =" & getUserName)
End Function
Upvotes: 0
Views: 618
Reputation: 8531
Public Function LookUpPermissionLevel(getUserName As String) As Integer
intPermissionLevel = DLookup("PermissionLevel", "tblEmployees", "Login ='" & getUserName & "'")
LookUpPermissionLevel=intPermissionLevel
End Function
Upvotes: 1
Reputation: 531
I think you were actually both correct. Thank you! This was what I needed to do:
intPermissionLevel = DLookup("[PermissionLevel]", "tblEmployees", "[Login]='" & getUserName & "'")
Upvotes: 0