Solved

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

Posted on 2014-04-11
3
562 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Supress Detail 4 17
VBA Shell can't Find Word document 11 38
Access 2016 Merge Tables 8 25
DCount using "OR" 4 16
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

772 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

12 Experts available now in Live!

Get 1:1 Help Now