I'm creating an application where I have multiple levels of access. I have created a function using DLookup using VB:
Private Sub Form_Load()
'Retrives "HasAccess" Field from the table "tblHasAccess" where the AccessLevelID = Current users access level ID
If (DLookup("[HasAccess]", "tblHasAccess", "UserLevel = UserLevel" & "[FormName]='" Me.Name & "'")) = False Then
MsgBox "You do not have the permissions required to access this location."
DoCmd.Close acForm, Me.Name
So upon loading of this form, the "HasAccess" field from the table "tblHasAccess" is retrieved where the UserLevel (Temp variable from the login form code) and the current form is false meaning the HasAccess checkbox in the database is unchecked then close the form and deny access of the form on the program.
However, all users are passing through, when they shouldn't be. I was wondering if anyone could help me. I have attached the login form code and DLookup function. I believe it could be a syntax problem with my DLookup function and the variable UserLevel.