Can you check this code as it is erroring out saying:
"Run-time Error '2001':
You cancelled the previous operation
Can you tell me the error of my ways in the code below? Where should I put it (Form_Load, Form_Open, etc.?):
Private Sub Form_Load()
'Checks User Security
Dim UserName As String
UserName = Environ$("USERNAME")
If DLookup("[Administrator]", "tblClaimHandlers", "[Alias]=UserName") = True Then
GoTo 1
ElseIf DLookup("[Administrator]", "tblTeam", "[TMAlias]=UserName") = True Then
GoTo 1
ElseIf DLookup("[Administrator]", "tblSection", "[SMAlias]=UserName") = True Then
GoTo 1
Else
MsgBox "You do not have permission to view this section. Contact your administrator to gain access.", vbExclamation, "Security Warning"
DoCmd.Close
End If
1
End Sub
Besides that, I'd like to create a coded procedure that I can call On Load or On Open instead of having to insert the code below in every form's code module. That for obvious reasons, but most because of any updates I make, I will only have to make them in one spot.
Thanks!!
"Run-time Error '2001':
You cancelled the previous operation
Can you tell me the error of my ways in the code below? Where should I put it (Form_Load, Form_Open, etc.?):
Private Sub Form_Load()
'Checks User Security
Dim UserName As String
UserName = Environ$("USERNAME")
If DLookup("[Administrator]", "tblClaimHandlers", "[Alias]=UserName") = True Then
GoTo 1
ElseIf DLookup("[Administrator]", "tblTeam", "[TMAlias]=UserName") = True Then
GoTo 1
ElseIf DLookup("[Administrator]", "tblSection", "[SMAlias]=UserName") = True Then
GoTo 1
Else
MsgBox "You do not have permission to view this section. Contact your administrator to gain access.", vbExclamation, "Security Warning"
DoCmd.Close
End If
1
End Sub
Besides that, I'd like to create a coded procedure that I can call On Load or On Open instead of having to insert the code below in every form's code module. That for obvious reasons, but most because of any updates I make, I will only have to make them in one spot.
Thanks!!