User level access to data entry

  • Thread starter Thread starter Sandy H
  • Start date Start date
S

Sandy H

Hi
I have a database that has been set up with 3 levels of user access. Read
Only User, Editing User and Administrator. My client has just asked me if
we can allow a read only user to edit one field in a particular form. There
are about 40 data fields on this form and for the sake of being a bit lazy,
wonder if there is an easy way to allow a read only user to edit this field.
At the moment, when they log in, the form properties are set as follows:
If intUserLevel = 2 Then
Me.Form.AllowAdditions = False
Me.Form.AllowDeletions = False
Me.Form.AllowEdits = False
end if
The only way I can think of to do this is to add a tag to all fields and
disable all but the one the user needs to edit. Is there another more
efficient way of doing this?

Thanks in advance
Sandy
 
You only need to tag the control you want to unlock. Paste the following
code into a standard module and call it in the form's open or current event,
passing the form's name. The example enables a command button only, but you
can lock or disable any control.

If UserLevel = 2 Then Me.cmdClose.Tag = 2

Public Sub LockIt(frm As Form)
' Arvin Meyer 11/1/04
On Error Resume Next
Dim ctl As Control

For Each ctl In frm.Controls
With ctl

Select Case .ControlType
Case acTextBox
ctl.Locked = True

Case acComboBox
ctl.Locked = True

Case acListBox
ctl.Locked = True

Case acCheckBox
ctl.Locked = True

Case acToggleButton
ctl.Locked = True

Case acCommandButton
If ctl.Tag = 2 Then
ctl.Enabled = True
End If

Case acSubform
ctl.Locked = True

Case acOptionGroup
ctl.Locked = True

Case acOptionButton
ctl.Locked = True

End Select
End With
Next ctl
Set ctl = Nothing
Set frm = Nothing

End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
hi Sandy,

Sandy said:
The only way I can think of to do this is to add a tag to all fields and
disable all but the one the user needs to edit. Is there another more
efficient way of doing this?
Depends on the definiton of "efficient". I would prefer an edit dialog
(OnDblClick) for this field, so you don't have to touch your security
code in general.


mfG
--> stefan <--
 
Thanks guys. All fixed.
Sandy

stefan hoffmann said:
hi Sandy,


Depends on the definiton of "efficient". I would prefer an edit dialog
(OnDblClick) for this field, so you don't have to touch your security
code in general.


mfG
--> stefan <--
 
Back
Top