lisaharris
Programmer
I'm using an IF statement to verify the windows system user that is clicking a button on a form in Access. The list is going to get lengthy and would be easier to maintain in a table within the database rather than hard-code into the VBA each time there's a change. I've already created a table called WaiverAuthority with one field called Supv containing the usernames that can click this button.
Any help with recoding that IF statement below will be GREATLY appreciated!!
Any help with recoding that IF statement below will be GREATLY appreciated!!
Code:
Private Sub Command1_Click()
Dim UserNameVBA As String
UserNameVBA = VBA.Interaction.Environ("USERNAME")
If UserNameVBA = "lhadmin" Or UserNameVBA = "jscarpa" Or UserNameVBA = "wholling" Or UserNameVBA = "cscott" Then GoTo YouPass Else: GoTo NoPass
NoPass:
MsgBox ("User " & UserNameVBA & " does not have access to this function.")
Exit Sub
YouPass:
Application.DoCmd.OpenForm "Waiver Screen"
Exit Sub
End Sub