Solved

Locking and Unlocking Fields on a Form

Posted on 2014-01-05
2
289 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IIF help, YN field 7 22
MS Access from Delphi 31 32
Part 2 to aggregate query solved qtn 12 37
Advice on Listbox or Listview usage 3 16
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

809 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