View Single Post
  #15  
Old January 31st, 2009, 02:52 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
Marshall Barton
external usenet poster
 
Posts: 5,361
Default navigating to different records in a read only form

Paul wrote:
Since I need to have the form change between allowing and not allowing edits
depending on who the user is, I guess I could loop through all the controls,
changing the Locked property as appropriate.



Sure. That's where the idea of using the Tag property comes
in.

I use a public procedure in a standard module to take care
of it for any form. Gina's use of different Tag settings
for different types of users is fine if that's your
situation, but a simple edit/no edit procedure, you could
just set the Tag property to LOCK or leave it blank:

Public Sub SetLocks(frm As Form, OnOff As Boolean)
Dim ctl As Control
For Each ctl In frm.Controls
If ctl.Tag = "LOCK" Then ctl.Locked = OnOff
Next ctl
End Sub

Then you can call it from any form to allow changes:
SetLocks Me, False
or to prevent changes:
SetLocks Me, True
Or from a main form to allow changes in a subform:
SetLocks Me.subformcontrol.Form, False
or ...

--
Marsh
MVP [MS Access]