Solved

Locking and Unlocking Fields on a Form

Posted on 2014-01-05
2
288 Views
Last Modified: 2014-01-05
Hi,

I have a form the most of the time needs to be read only.

Up 'til now I have locked all the text boxes.

The users have been able to unlock a particular field by clicking a button that toggles the Locked property for that text box.

I now want to unlock all the fields by the click of one toggle button.  What's the best way to do this?

a) Using the Allow Edits property instead
b) Looping through the text boxes (but I don't know how)
c) Setting each control to unlocked one at a time.
d) another way

Cheers
0
Comment
Question by:LJKMartin
2 Comments
 
LVL 29

Accepted Solution

by:
IrogSinta earned 500 total points
ID: 39757460
This depends on whether you also want to keep the individual unlock functionality.  If you don't need that feature anymore then setting the AllowEdits property to True would be the simplest way.  You would first need to set the Locked properties of all textboxes back to False and then your button to unlock them should have AllowEdits = False.

However, if you would like to have the individual unlock along with a group unlock, you would need your button to call a procedure that loops through your buttons and sets their Locked properties to False.  You could use something like this:
    Dim ctl As Control
    
    For Each ctl In Me
        If ctl.ControlType = acTextBox Then ctl.Locked = False
    Next

Open in new window

0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 39757466
I would use a) ... perhaps combined with AllowAdditions = False

/gustav
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

896 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

17 Experts available now in Live!

Get 1:1 Help Now