1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Visual Basic Code with Microsoft Access (DLookup)

Discussion in 'Software Development' started by rocknroller404, Aug 7, 2018.

Thread Status:
Not open for further replies.
  1. rocknroller404

    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
     

    Attached Files:

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1214119

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice