[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2014-04-11
3
Medium Priority
?
598 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 66

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 39

Accepted Solution

by:
PatHartman earned 1200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

650 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