Amy E. Baggott said:
My database is an .mdb and I am using an Access Workgroup with the user
security and permissions set up through the wizard in Access.
Then you can either check the value of CurrentUser() and enable/disable (or
show/hide) the button based on the user, like this:
'----- start of example code -----
Private Sub Form_Open(Cancel As Integer)
Dim blnCancellingAllowed As Boolean
Select Case CurrentUser()
Case "Amy Baggott"
blnCancellingAllowed = True
Case "Amy's Close Friend"
blnCancellingAllowed = True
Case Else
blnCancellingAllowed = False
End Select
Me.cmdCancel.Enabled = blnCancellingAllowed
' ** or ** Me.cmdCancel.Visible = blnCancellingAllowed
End Sub
'----- end of example code -----
Of course, you may want to store the authorized users in a table and use a
DLookup to find out if CurrentUser() is authorized, instead of hard-coding
the values. You'd need to user ULS to protect that table against
unauthorized changes.
*** OR ***
You may have your users classified into groups, in which case you can check
whether the current user is in a group that is authorized to cancel. For
that you might use this function:
'----- start of function code -----
Function fncUserIsInGroup(GroupName As String) As Boolean
' Returns True if the current user is a member of the specified
' security group; False if not, or if the group doesn't exist, or
' if an error occurs reading the groups.
Dim ws As Workspace
Set ws = DBEngine.Workspaces(0)
On Error Resume Next
fncUserIsInGroup = _
(ws.Users(CurrentUser).Groups(GroupName).Name = GroupName)
Set ws = Nothing
End Function
'----- end of function code -----