I have a form the end user logs in on. When successful it opens a menu form that grants access to other forms. I want to restrict these forms to read only or full rights based on their userlevel. If the userlevel is set to 2 it should be read only.
So I have a query that pulls their userlevel as follows on form open.
Here's my code:
So, if I Dim UserLevel as Integer I get a type mismatch error on line 3 even though the query is pulling an integer. I tried using Variant, but then it skips my if statement and grants access from the else statement.
Any suggestions?
So I have a query that pulls their userlevel as follows on form open.
Here's my code:
Code:
Dim UserLevel As Integer
UserLevel = "SELECT UserT.AccessLevelID FROM UserT WHERE (((UserT.Username) = " & [Forms]![CredentialsF]![txtLoginID] & "));"
If UserLevel = 2 Then
MsgBox "Access granted with limited permissions."
'Me.AllowEdits = False
'Me.AllowAdditions = False
'Me.AllowDeletions = False
'DoCmd.OpenForm "AcquiredF"
Else
MsgBox "Access granted."
DoCmd.OpenForm "AcquiredF"
End If
So, if I Dim UserLevel as Integer I get a type mismatch error on line 3 even though the query is pulling an integer. I tried using Variant, but then it skips my if statement and grants access from the else statement.
Any suggestions?