Help with code

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
 
D

Dennis

It all depends on how a Supervisor status is determined. Do you log in as
Supervisor ? in which case just swap your checking line around to

If ZZNAV_OWNER = CurrentUser() Or CurrentUser() = "Supervisor" Then
DoCmd.Hourglass True
....
....
Else
FormattedMsgBox "No Permission Given .....
...
End If
 
S

SF

I will try, Thank.

SF

Dennis said:
It all depends on how a Supervisor status is determined. Do you log in as
Supervisor ? in which case just swap your checking line around to

If ZZNAV_OWNER = CurrentUser() Or CurrentUser() = "Supervisor" Then
DoCmd.Hourglass True
....
....
Else
FormattedMsgBox "No Permission Given .....
...
End If

SF said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top