Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
 
Home   Courses   Seminars   Templates   Help   TechHelp   Forums   Contact   Join   Order   Logon  
 
 
Access Database Security Seminar
By Richard Rost   Richard Rost on Twitter Richard Rost on LinkedIn Email Richard Rost   12 years ago

Learn how to properly secure your Access databases. Control and monitor everything your users can do in the database. Manage the complete flow of data into your database. Click here for a Complete Outline of the seminar and the topics covered.

 

Locking Unlocking Fields Upload Images   Link 
Joseph O'Malley 
42 days ago
I have a subform which is bringing in linked data from another table, when writting the vba code for locking up all the fields & unlocking based on GroupID can I set all of that in the parent form or do I have to go into to the subform and write the code in there as well for the corresponding fields?
Adam Schwanz
42 days ago
Just lock the entire subform at once on the main form. Don't need to go in and lock them individually.
Joseph O'Malley
41 days ago
How would I go about doing that?
Richard Rost
41 days ago
From the parent form just say:

SubformName.Locked = TRUE

So let's say you wanted to LOCK or UNLOCK the ContactF (which is a subform on CustomerF) depending on the status of the IsActive field, you would say this in the OnCurrent event:

Private Sub Form_Current()
    If IsActive Then
        ContactF.Locked = False
    Else
        ContactF.Locked = True
    End If
End Sub


It's that easy. Don't forget the same code in the AfterUpdate event for the IsActive field itself.
Joseph O'Malley
41 days ago
Thank you so much for the reply. would be okay with locking the whole subform at first but how would I go about unlocking specific fields within the subform based on GroupID? I apologize if I am missing something.
Richard Rost
41 days ago
Same thing, just a little more complicated.

ContactF.Form!FieldName.Locked = TRUE

Joseph O'Malley
41 days ago
Thank you so much for your help I really appreciate it. I'm getting an error and I was wondering if you can help he figure out were I'm going wrong

Private Sub Form_Current()
DIM ctl As Control

If ISUserInGroup(1) Then
Else
For Each ctl In Me

If ctl.ControlType = acTextBox or ctl.ControlType = acComboBox Then
ctl.Locked = True
End If

Next
For Each clt in Forms!MainForm.MySubform.Form!
If ctl.ControlType = acTextBox or ctl.ControlType = acComboBox Then
ctl.Locked = True
End If

Next
End If

If IsUserInGroup(2) Then
FieldName.Locked = False
Forms!MainForm.MySubform!FieldName.Locked = False

End If

End Sub


Adam Schwanz
41 days ago
Few things, maybe just my preference, but I like to just say 'do nothing if it's no code, easier to read.

If ISUserInGroup(1) Then
'do nothing
Else
For Each ctl In Me

This part has a spelling error, clt instead of ctl
For Each clt in Forms!MainForm.MySubform.Form!

These arent actually "FieldName" right? They're your real field names. Like ContactName.Locked = False etc, or do you have a field called fieldname?
If IsUserInGroup(2) Then
FieldName.Locked = False
Forms!MainForm.MySubform!FieldName.Locked = False
Add a Reply

Show All Comments

Start a NEW Conversation
 
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.
 
Subscribe
 

You may want to read these articles from the 599CD News:

5/14/2021Quick Queries #4
5/12/2021Markup
5/9/2021Access D29 Started
5/9/2021Access Developer 30
5/9/2021Access Developer 30 Lessons
5/9/2021Access Developer 30
5/8/2021Data Entry
5/2/2021Split Commissions
4/30/2021Close Form
4/30/2021Close All Forms
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
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
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
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
Keywords: access database security seminar  PermaLink