Computer Learning Zone CLZ Access Excel Word Windows

You know it's true... Every disaster movie begins with a scientist being ignored.

-Neil deGrasse Tyson
 
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 
Lock Code Not Working
jannette jones 
    
6 years ago
when i write my code for production user the form does not change im not sure why its doing this but here my code<>

Private Sub Form_Current()
'dim the control
Dim ctl As Control
'if he user is in admin do not lock the fields.
'If IsUserInGroup(1) Then
    'dont lock the form

For Each ctl In Me
    If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
        ctl.Locked = True
        ctl.BackColor = RGB(200, 200, 200) 'grey
    End If
Next
'End If

'Production Users unlocked fields

If IsUserInGroup(4) Then
    TSubmittedDate.Locked = False
    TRequestor_Name.Locked = False
    TDepartment.Locked = False
    TAreaAffected.Locked = False
    TProjectSummary.Locked = False
    TProjectDetails.Locked = False
    TContactPhoneNo.Locked = False
    TDepartmentManager.Locked = False
    TReqCompletedDate.Locked = False
    TSubmittedDate.BackColor = vbWhite
    TRequestor_Name.BackColor = vbWhite
    TDepartment.BackColor = vbWhite
    TAreaAffected.BackColor = vbWhite
    TProjectSummary.BackColor = vbWhite
    TProjectDetails.BackColor = vbWhite
    TContactPhoneNo.BackColor = vbWhite
    TDepartmentManager.BackColor = vbWhite
    TReqCompletedDate.BackColor = vbWhite
End If

End Sub
Richard Rost  @Reply  
          
6 years ago
It looks OK to me. I'm assuming your IsUserInGroup function is written correctly. Try stepping through it.
James Gray  @Reply  
     
6 years ago
Maybe I am just looking at it wrong but isn't the If statement remarked out?
Richard Rost  @Reply  
          
6 years ago
Yeah, she's got some lines REMmed out but everything matches up. It comes out to basically this when you cut it down:

For Each ctl In Me
    If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
        ctl.Locked = True
        ctl.BackColor = RGB(200, 200, 200) 'grey
    End If
Next

If IsUserInGroup(4) Then
    TSubmittedDate.Locked = False
    TRequestor_Name.Locked = False
    ...
    TSubmittedDate.BackColor = vbWhite
    TRequestor_Name.BackColor = vbWhite
End If

As far as I can see everything SHOULD work. Again, this is one of those situations where I'd really need to see the database.
Richard Rost  @Reply  
          
6 years ago
Oh... I just saw it... change this line:

For Each ctl In Me

to this:

For Each ctl In Me.CONTROLS
Richard Rost  @Reply  
          
6 years ago
Give James the assist there because he made me re-look at the code. :)
James Gray  @Reply  
     
6 years ago
I was referring to the If statement that checked if user was in Group(1).  That looks like it is remmed out so that the lock code never runs since the user group check isn't performed.  I didn't see the me.controls issue....
jannette jones OP  @Reply  
    
6 years ago
James and Richard i made the recommended changes and still not working correctly
Richard Rost  @Reply  
          
6 years ago
Does the code work without IsUserInGroup? What exactly is NOT working?

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/6/2026 3:55:39 PM. PLT: 1s