Solved

How to enable radio buttons in a form opened as read-only ?

Posted on 2014-04-11
3
564 Views
Last Modified: 2014-04-15
Hi

I have an Access 2007 app with various forms which some users use for data maintenance. I now want to make it available to read-only users, so I open the forms in the app in normal or read-only mode depending on the user. So far so good.

However, on one form I am using a battery of radio buttons to allow the user to select subsets of the data (filter function, but programmed through VBA, as many of these filters can be combined). Now there radio buttons are disabled in read-only mode, and enabling them through code in the forms load event doesn't work. So the read-only users won't be able to filter, which is no good.

Is there a way I can keep the basic read-only feature but have my radio buttons to work ? Or do I have to change the radio buttons to pushbuttons, as these work in read-only mode ?
0
Comment
Question by:bthouin
3 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39994649
Try setting the Locked property to True on the entire Option Group that holds these radio buttons.  

If you're not using an Option group, the set the Locked property to True on each radio button.
0
 
LVL 34

Accepted Solution

by:
PatHartman earned 300 total points
ID: 39995059
Now that ULS has been deprecated, that is a common problem.  To solve the problem, I created a generic solution that I use in all my databases.  The security checking may vary from app to app but the lock/unlock code is generic and can be used by every form in every database, you just need to set the tag property of the controls you want to control independently and then just run the common code whenever you want to lock or unlock a form's controls.

I posted part of the security check code I use in the Current event of each form.  The code determines the security level of the logged in user and locks/unlocks the form controls one by one appropriately.     The LockControls procedure is 100% generic.  You can place it directly in a module in your application.  Put it in a standard module rather than in a form's class module because you want the code to be usable from EVERY form, not just the one that contains it.   There are two keywords I use - "Lock" and "NoLock".  You use "Lock" in the tag property of any control that you always want to be locked regardless of the security level of the user.  Fields like changed by and changed date fall into this category.  Those fields are always system set and users never modify them.  the other value is "NoLock" and you use that for controls that you always want to be unlocked regardless of the security level of the user.  Those would be things like the search/filter fields and print buttons.

'''this goes in the current event of each form
    If Forms!frmlogin!chkOKCLI = True Then
        Call LockControls(Me, False)        'unlock  <<<<<<<< this is the operative piece
        If Forms!frmlogin!txtLevel > 8 Then
            Me.cmdDelete.Enabled = True
        Else
            Me.cmdDelete.Enabled = False
        End If
    Else
        Call LockControls(Me, True)         'lock  <<<<<<<< this is the operative piece
    End If


Public Sub LockControls(frm As Form, bLock As Boolean)
    Dim ctl As Control
    For Each ctl In frm.Controls
    Select Case ctl.ControlType
        Case acTextBox, acComboBox, acListBox, acCheckBox
            Select Case ctl.Tag
                Case "NoLock"
                    ctl.Locked = False
                Case "Lock"
                    ctl.Locked = True
                Case Else
                    ctl.Locked = bLock         'toggle locks
            End Select
    End Select
Next ctl
Set ctl = Nothing

End Sub

Open in new window

0
 
LVL 1

Author Comment

by:bthouin
ID: 40001720
Hi

@Jim: doesn't work. It seems that if the form is opened as read-only, unlocking or enabling radio buttons doesn't do anything.

@pat: Yep, I used that technique in an other project, I guess I will have to do that: open the form normally (i.e. not read-only), then lock whatever has to be locked with your LockControls code, that leave the rest as is... Just did it: it works like a breeze ! Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sending email from List Data 2 51
Run Time Error 3075 15 45
Alter an update query which rounds 7 33
access 7 26
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now