I am still having a hard time learning how to properly use functions.
I find myself repeating a the same process over and over and would like to create a module with a public function.
The code I keep repeating is a simple one. It checks username via Environ("Username") then with another variable, I list a few different usernames to return true/false.
I would possibly have 2-3 different variables that return true/false vs a list of usernames, then return that to the calling procedure to determine if the sub can continue, or exits with a message box. Could someone please give me a hand with writing this function?
I find myself repeating a the same process over and over and would like to create a module with a public function.
The code I keep repeating is a simple one. It checks username via Environ("Username") then with another variable, I list a few different usernames to return true/false.
Code:
Dim Admin As Boolean
Dim User As String
User = Environ("Username")
Admin = (User = "user1" Or User = "user2")
If Admin = False Then
MsgBox ("You are not authorized to use this feature")
Exit Sub
Else
DoCmd.OpenForm "NameMappingEditFrm", acNormal
End If
End Sub
I would possibly have 2-3 different variables that return true/false vs a list of usernames, then return that to the calling procedure to determine if the sub can continue, or exits with a message box. Could someone please give me a hand with writing this function?