B
BruceM
I have a database for problem reporting, with user-level security in place
(test version so far). Each record involves four steps: Problem
Description, Response, Follow-up, and Final Approval. I want to make sure
that only the person who wrote the Problem Description can edit it; the same
for Response, Follow-up, and Final Approval.
Each section (step) is on its own page of a tab control. The following
function, which I call at the tab controls Change event and at the form's
Current event, seems to work, but it seems convoluted. I keep thinking I
must be missing something that would simplify this.
Public Function EditAllow(frm As Form)
Dim ctl As Control
Dim strTabCapt As String
strTabCapt = frm.tabCAR.Pages(frm.tabCAR.Value).Caption ' The tab
page's caption
Select Case strTabCapt
Case "Problem Description"
If frm.CurUser = CurrentUser Then
' The CurrentUser is inserted into the CurUser field
' when the Problem Description is initially entered
For Each ctl In frm.Controls
If ctl.Tag = "PD" Then
ctl.Locked = False
Else
Select Case ctl.ControlType
Case acTextBox, acComboBox, acSubform
ctl.Locked = True
End Select
End If
Next ctl
Else
For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acSubform
ctl.Locked = True
End Select
Next ctl
End If
Case "Response"
If frm.OwnerSig = CurrentUser Then
etc. etc.
End Select
End Function
Case "Response", Case "Follow-up", and Case "Final Approval" are the same as
Case "Problem Description", so I didn't repeat the code. I left out a few
other things that are not relevant to the question at hand, including a
provision that allows a member of the Admins group to edit any controls.
Again, each step is on its own page of the tab control. If the person
currently logged on is the same person who entered the information at a
particular step (Problem Description, Response, etc.), that person can edit
the controls on that tab page. The reason for checking the tag property is
that there are controls on the form but not on the tab page that need to
stay locked.
These four lines occur several times:
Select Case ctl.ControlType
Case acTextBox, acComboBox, acSubform
ctl.Locked = True
End Select
I would think it is possible to turn those into a function or constant or
something, and use a single line of code in place of the four lines in the
function, but I can't quite figure out how to go about that. I haven't had
any luck getting it to work as a function. Before I try creating a constant
or a string or something I would like to know if I am on the right track.
Any ideas to streamline this would be appreciated.
I will be away until Monday morning, so please don't think me rude if you
respond and I don't acknowledge it right away.
(test version so far). Each record involves four steps: Problem
Description, Response, Follow-up, and Final Approval. I want to make sure
that only the person who wrote the Problem Description can edit it; the same
for Response, Follow-up, and Final Approval.
Each section (step) is on its own page of a tab control. The following
function, which I call at the tab controls Change event and at the form's
Current event, seems to work, but it seems convoluted. I keep thinking I
must be missing something that would simplify this.
Public Function EditAllow(frm As Form)
Dim ctl As Control
Dim strTabCapt As String
strTabCapt = frm.tabCAR.Pages(frm.tabCAR.Value).Caption ' The tab
page's caption
Select Case strTabCapt
Case "Problem Description"
If frm.CurUser = CurrentUser Then
' The CurrentUser is inserted into the CurUser field
' when the Problem Description is initially entered
For Each ctl In frm.Controls
If ctl.Tag = "PD" Then
ctl.Locked = False
Else
Select Case ctl.ControlType
Case acTextBox, acComboBox, acSubform
ctl.Locked = True
End Select
End If
Next ctl
Else
For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acSubform
ctl.Locked = True
End Select
Next ctl
End If
Case "Response"
If frm.OwnerSig = CurrentUser Then
etc. etc.
End Select
End Function
Case "Response", Case "Follow-up", and Case "Final Approval" are the same as
Case "Problem Description", so I didn't repeat the code. I left out a few
other things that are not relevant to the question at hand, including a
provision that allows a member of the Admins group to edit any controls.
Again, each step is on its own page of the tab control. If the person
currently logged on is the same person who entered the information at a
particular step (Problem Description, Response, etc.), that person can edit
the controls on that tab page. The reason for checking the tag property is
that there are controls on the form but not on the tab page that need to
stay locked.
These four lines occur several times:
Select Case ctl.ControlType
Case acTextBox, acComboBox, acSubform
ctl.Locked = True
End Select
I would think it is possible to turn those into a function or constant or
something, and use a single line of code in place of the four lines in the
function, but I can't quite figure out how to go about that. I haven't had
any luck getting it to work as a function. Before I try creating a constant
or a string or something I would like to know if I am on the right track.
Any ideas to streamline this would be appreciated.
I will be away until Monday morning, so please don't think me rude if you
respond and I don't acknowledge it right away.