?
Solved

Locking and Unlocking Fields on a Form

Posted on 2014-01-05
2
Medium Priority
?
314 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 2000 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 52

Expert Comment

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

/gustav
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

840 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