locking form sections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can I lock a section(the detail section to be exact) via VBA. I would want to
allow the detail section to have data enetered based on which user is logged
in? I already know how to pass user information to the form so the option to
lock is all i need.
Thanks
 
I don't believe you can lock a section, but you could loop through controls
and lock them one at a time. It would look something like this ...


Public Function LockUnlockControls(ByVal fLock as Boolean) As Boolean

dim ctl as control

for each ctl in me.Controls
If ctl.ControlType = acTextBox or ctl.ControlType = acComboBox Then
ctl.Locked = fLock
End If
next
End Function


Now, you could vary this code by puting a comma delimited string of users
on the Tag property and if the current user is in that list, or better yet, if their
ROLE is in that list, then the control could be unlocked, but you get the idea.
 
sturner333 said:
Can I lock a section(the detail section to be exact) via VBA. I would
want to allow the detail section to have data enetered based on which
user is logged in? I already know how to pass user information to the
form so the option to lock is all i need.
Thanks

You could use the Tag property to identify the controls to be locked or
unlocked.

Or you could use the Controls collection of the section itself to touch
just the controls in that section:

Dim ctl As Access.Control

For each ctl In Me.Section(acDetail).Controls

' ... lock or unlock the control ...

Next ctl
 
That will work great. What is the Tag property you mention?
Thanks for your help!
 
That will work great. What is the Tag property you mention?
Thanks for your help!
 
sturner333 said:
That will work great. What is the Tag property you mention?

Every control has a Tag property -- you'll find it on the Other tab of
the control's property sheet in Design View. It's a text property, and
you can put any string you want in it at design time, and read and even
modify it at run time. So you could have code that loops through the
form's controls and checks for a special value in the control's Tag
property to determine whether the control should be locked or unlocked.
For example,

Dim ctl As Access.Control

For Each ctl in Me.Controls
If ctl.Tag = "LockMe" Then
ctl.Locked = True
End If
Next ctl
 
sturner333 said:
Can I lock a section(the detail section to be exact) via VBA. I would want
to
allow the detail section to have data enetered based on which user is
logged
in? I already know how to pass user information to the form so the option
to
lock is all i need.
Thanks
 

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

Back
Top