S
SF
Hi,
I have the following code attach to a shortcut menu bar. This code would
check for owner of record before allow editing. This work fine for each
current user, Is there a way to allow a supervisor to edit as well, if yes
how to code it.
Function Edit()
'On Error GoTo Err_Edit
Dim Vfrm As Form, ctl As Control
Set Vfrm = Screen.ActiveForm.SubForm.Form
ZZNAV_OWNER = Screen.ActiveForm![SubForm].Form![Owner]
Vfrm.focus.SetFocus
If ZZNAV_OWNER <> CurrentUser() Then
FormattedMsgBox "No Permission Given@You are not the current owner of
this object.@You are not permitted to add or edit records in the current
object.", 48, "Warning"
Else
DoCmd.Hourglass True
Vfrm.AllowEdits = True
For Each ctl In Vfrm.Controls
If Left(ctl.Tag, 1) = "2" Then
With ctl
.Visible = False
End With
ElseIf Left(ctl.Tag, 1) = "3" Then
With ctl
.Visible = True
.RowSource = "cmb" & .Name
End With
ElseIf Left(ctl.Tag, 1) = "4" Then
With ctl
.Enabled = True
End With
End If
Next ctl
DoCmd.Hourglass False
End If
'Exit_Edit:
'Exit Function
'
'Err_Edit:
' MsgBox Err.Description
' DoCmd.Hourglass False
' Resume Exit_Edit
End Function
I have the following code attach to a shortcut menu bar. This code would
check for owner of record before allow editing. This work fine for each
current user, Is there a way to allow a supervisor to edit as well, if yes
how to code it.
Function Edit()
'On Error GoTo Err_Edit
Dim Vfrm As Form, ctl As Control
Set Vfrm = Screen.ActiveForm.SubForm.Form
ZZNAV_OWNER = Screen.ActiveForm![SubForm].Form![Owner]
Vfrm.focus.SetFocus
If ZZNAV_OWNER <> CurrentUser() Then
FormattedMsgBox "No Permission Given@You are not the current owner of
this object.@You are not permitted to add or edit records in the current
object.", 48, "Warning"
Else
DoCmd.Hourglass True
Vfrm.AllowEdits = True
For Each ctl In Vfrm.Controls
If Left(ctl.Tag, 1) = "2" Then
With ctl
.Visible = False
End With
ElseIf Left(ctl.Tag, 1) = "3" Then
With ctl
.Visible = True
.RowSource = "cmb" & .Name
End With
ElseIf Left(ctl.Tag, 1) = "4" Then
With ctl
.Enabled = True
End With
End If
Next ctl
DoCmd.Hourglass False
End If
'Exit_Edit:
'Exit Function
'
'Err_Edit:
' MsgBox Err.Description
' DoCmd.Hourglass False
' Resume Exit_Edit
End Function