Tech Support Guy banner

Visual Basic Code with Microsoft Access (DLookup)

1192 Views 0 Replies 1 Participant Last post by  rocknroller404
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
Not open for further replies.
1 - 1 of 1 Posts
1 - 1 of 1 Posts
Status
Not open for further replies.
Top