Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
UnlockLock Multiple Controls
Colby Wolford 
    
3 years ago
Context:
I created a Dashboard form with a "What You're Looking For" section of check box and text box. This section serves as a visual reminder of job preferences. I have an Unlock/Lock button that I want to change the controls' states so edits aren't accidentally performed.

Issue:
I'm not sure how to code the Unlock/Lock button to do this. Below is my code.

*****
Private Sub Form_Current()

   Me.PositionTitle.Locked = True
   Me.chkFT.Locked = True
   Me.chkPT.Locked = True
   Me.chkHybrid.Locked = True
   Me.chkRemote.Locked = True
   Me.chkExempt.Locked = True
   Me.chkNonExempt.Locked = True
   Me.chkRelocate.Locked = True
   Me.chkTravel.Locked = True
   Me.Hourly.Locked = True
   Me.Yearly.Locked = True

End Sub
-------
Private Sub btnEdit_Click()

    If Me.PositionTitle.Locked = True Then
        Me.chkFT.Locked = True
        Me.chkPT.Locked = True
        Me.chkHybrid.Locked = True
        Me.chkRemote.Locked = True
        Me.chkExempt.Locked = True
        Me.chkNonExempt.Locked = True
        Me.chkRelocate.Locked = True
        Me.chkTravel.Locked = True
        Me.Hourly.Locked = True
        Me.Yearly.Locked = True
        Me.btnEdit.Caption = "Unlock"
    Else
        Me.chkFT.Locked = False
        Me.chkPT.Locked = False
        Me.chkHybrid.Locked = False
        Me.chkRemote.Locked = False
        Me.chkExempt.Locked = False
        Me.chkNonExempt.Locked = False
        Me.chkRelocate.Locked = False
        Me.chkTravel.Locked = False
        Me.Hourly.Locked = False
        Me.Yearly.Locked = False
        Me.btnEdit.Caption = "Lock"
    End If
        
End Sub
*****

This code is neither unlocking the controls nor switching between the button's caption of "Lock" or "Unlock".

What am I missing? I'm guessing that I'm either missing something super simple or that I've completely misguided myself.
Colby Wolford OP  @Reply  
    
3 years ago

Kevin Robertson  @Reply  
          
3 years ago
I would look at the caption of the button to determine whether the controls should be locked or unlocked.

Private Sub btnEdit_Click()

    If btnEdit.Caption = "Lock" Then
        chkFT.Locked = True
        chkPT.Locked = True
        chkHybrid.Locked = True
        chkRemote.Locked = True
        chkExempt.Locked = True
        chkNonExempt.Locked = True
        chkRelocate.Locked = True
        chkTravel.Locked = True
        Hourly.Locked = True
        Yearly.Locked = True
        btnEdit.Caption = "Unlock"
    Else
        chkFT.Locked = False
        chkPT.Locked = False
        chkHybrid.Locked = False
        chkRemote.Locked = False
        chkExempt.Locked = False
        chkNonExempt.Locked = False
        chkRelocate.Locked = False
        chkTravel.Locked = False
        Hourly.Locked = False
        Yearly.Locked = False
        btnEdit.Caption = "Lock"
    End If
        
End Sub
Colby Wolford OP  @Reply  
    
3 years ago
Thanks for that idea, Kevin. Your help is greatly appreciated.

Unfortunately, the button's still not unlocking the controls; the caption is changing, though, so I'm getting closer. I've tried closing the and reopening the database.
Colby Wolford OP  @Reply  
    
3 years ago
I also checked the all the control properties, and they're all set to Locked: No / Enabled: Yes.
Stefan Pinne  @Reply  
    
3 years ago
The part under form_current needs to be under Form_Load, as fas as I understand this.
Colby Wolford OP  @Reply  
    
3 years ago
[SOLVED!]

Thanks, Kevin, everything works now. It seems there were two missing controls from my list and those were the two that I tested and weren't working. After testing everything individually, I narrowed it down and compared it to my list and realized I skipped them.

Thank you!

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/7/2026 10:51:45 PM. PLT: 1s