Computer Learning Zone CLZ Access Excel Word Windows

Life is not fair. Get used to it.

-Bill Gates
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Database Security Seminar    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Variable required error
Jannette Jones 
    
6 years ago
i get an error when i try to run this code can you help
Private Sub Form_Current()
    'Locked the fields with a For Loop
    Dim Ctl As Control
    For Each Ctl.ControlType In Me
        If Ctl.ControlType = acTextBox Or Ctl.ControlType = acComboBox Then
            Ctl.Locked = True
            Ctl.BackColor = RGB(220, 220, 220) 'smokeyn grey
            
        End If
Richard Rost  @Reply  
          
6 years ago
Code looks OK to me. What line gives the error? I assume you close your loop and sub.
Jannette Jones OP  @Reply  
    
6 years ago
Varriable required cant assign to this expression
Jannette Jones OP  @Reply  
    
6 years ago
Rick i found what i did wrong i put ctl.controltype in For line
Richard Rost  @Reply  
          
6 years ago
Ah. Yep. You got that one past me too. It's sometimes difficult to debug code without actually running it yourself. I just glanced at it and missed that. You're right it should be:

For Each Ctl in Me

Good catch.

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

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 1:40:23 AM. PLT: 0s