[AccessD] can't select data in control when AllowEdit false

Jim Dettman jimdettman at verizon.net
Fri Sep 10 07:43:39 CDT 2010


John,

  Yeah, pretty silly.  The way I've always handled this to put any "control"
type controls that I always want active in the header of the form.
Everything else goes in the detail section.  I have a routine (see below)
that loops through all the controls and if they are in the detail section
and enabled, I set their lock property.

  You could also use the controls tag property as a flag as to whether or
not you wanted to lock/unlock the control.

Jim.

Function StdLockForm(frm As Form, intState As Integer)

        'Lock/unlock all the fields in the detail section of the form that
are enabled.

        Const RoutineName = "StdLockForm"
        Const Version = "1.2.0"

        Dim ctrl As Control
        
10      On Error Resume Next

20      For Each ctrl In frm.Controls
          ' Don't do any control execpt those in the detail section
30        If ctrl.Section = acDetail Then
40          With ctrl
50            Select Case .ControlType
                Case acCommandButton
60                ctrl.Enabled = Not intState
70              Case Else
80                If ctrl.Enabled = True Then ctrl.Locked = intState
90            End Select
100         End With
110       End If
120     Next ctrl

End Function

 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Friday, September 10, 2010 7:42 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] can't select data in control when AllowEdit false

Yes, that is a workaround, and I have used that workaround.

Now you have a form with 200 controls on it...

In the specific case I just ran into, the form itself is bound, but I have a
list box that I 
populate programmatically that is not bound to any data field.  I want to
not allow the user to edit 
the data in the form, but select one or more items in the list in order to
push a button to cause 
something to happen.  Setting the form.AllowEdit false locks my list, even
though the list is not 
even bound to data.

Silly in my humble opinion.

I am writing a Presentation Level Security System.  It is not uncommon to
want to prevent the user 
from editing the data in the form and yet perform activities on the form.
But with the Access 
system, if I just set the AllowEdits false it pretty much locks down the
form.  NOT my intention!

So now I have to decide whether the user will be wanting to perform some
activity on the form and 
NOT set the AllowEdits property but instead lock down just the controls that
can modify the data.

Pretty darned silly in my humble opinion.

John W. Colby
www.ColbyConsulting.com

On 9/10/2010 7:06 AM, Stuart McLachlan wrote:
> Set the form to allow edits but set individual controls to Enabled = Yes
and Locked = Yes?
>
> On 10 Sep 2010 at 6:37, jwcolby wrote:
>
>> I had forgotten this.
>>
>> Is there a way around it?  It is not uncommon to not allow the user to
>> edit the form's underlying record and yet need to click a button or
>> select an item from a list.
>>
>> --
>> John W. Colby
>> www.ColbyConsulting.com
>> --
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>>
>
>
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list