Issue with user permission (1 Viewer)

mo9204

New member
Local time
Today, 07:53
Joined
Feb 9, 2018
Messages
8
Code:

Private Sub Command32_Click()
Dim strUName As String
Dim RecordID As Long
Dim Permission As String

strUName = CreateObject("WScript.Network").UserName


Permission = Nz(DLookup("[Permission]", "LT_allUsers", "[Network_Login] = '" & strUName & "'"))

If Permission = "Dev" Then
DoCmd.OpenForm "frm_E_Users"
Else
MsgBox "You don't have permission"
End If



'DoCmd.OpenForm "Admin_allUsers"

End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 07:53
Joined
Feb 19, 2013
Messages
16,607
mo - are you making a statement or asking a question? and if asking a question, what is the issue?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:53
Joined
Feb 28, 2001
Messages
27,140
The line you highlighted does not superficially appear to have an error. The quotes balance as far as I can tell. So do the parentheses. (May I suggest a different color highlight for future reference? Yellow on white is VERY hard to read. Blue, green, red, or purple work just fine.)

Like CJ, I don't know what you are asking. But if I had to hazard a guess, I would say that your NZ() function is missing a second argument. The first is obviously the DLookup, and that is good as-is. However, if you want to do a text comparison, it would be good to assure that you get back "" (an empty string) from the NZ if there is something wrong with the lookup.

I have one other minor quibble. Your method of obtaining the username is a bit off, maybe. I always use Environ("Username") when in a domain-based environment.
 

Users who are viewing this thread

Top Bottom