Visual Basic Code with Microsoft Access (DLookup)

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

rocknroller404

Thread Starter
Joined
Aug 1, 2018
Messages
9
Hi All!

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




End If

End Sub

Intended functionality:
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.

Best wishes
 

Attachments

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top