Restricting entry on tab pages

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.



.



Relevant Pages

  • RE: disable text box via combo box
    ... are finding it difficult to understand your response ... "Sprinks" wrote: ... Loop through the controls, and disable ... > For Each ctl In Me.Controls ...
    (microsoft.public.access.forms)
  • Re: Container for programmatically positioning group of controls on form
    ... therefore the tab control serves no purpose for this particular use. ... controls, but since my controls are not in a perfectly orderly array, I'm ... Set the Tag property to something like G to identify the ... For Each ctl In Me.Comtrols ...
    (microsoft.public.access.formscoding)
  • Re: Container for programmatically positioning group of controls on form
    ... relationship among the controls other than they all move to ... therefore the tab control serves no purpose for this particular use. ... I could definitely see your method working well for a very ordered array of ... For Each ctl In Me.Comtrols ...
    (microsoft.public.access.formscoding)
  • Re: Container for programmatically positioning group of controls o
    ... Put your other controls over it, ... Then, create a subroutine which you pass the name of the rectangle, and the ... therefore the tab control serves no purpose for this particular use. ... For Each ctl In Me.Comtrols ...
    (microsoft.public.access.formscoding)
  • Looping through controls in a tab control
    ... I'm able to loop through controls on a form as follows ... foreach(Control ctl in col) ... However if the controls are on a tab control, i'm not able to access them progmatically. ...
    (microsoft.public.dotnet.framework.windowsforms)