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 
Lock Specific Record
James McMillan 
    
3 years ago
What is the VBA code to lock a SPECIFIC RECORD, not a field or a table, on exit from a field?
Kevin Yip  @Reply  
     
3 years ago
Records can only be all locked or all unlocked.  To disable editing for certain records, you need to design the form differently.  One way is to lock all records (AllowEdits set to false), put an Edit button on the form's header, and use form's Current event to enable or disable the button.  You can use any logic you want to do that.  For instance, if the record is too old, disable the Edit button, so the user can't edit the record.  Of course, you need a separate data entry form to open when the Edit button is clicked.
Alex Hedley  @Reply  
           
3 years ago
What determines whether a Record should be locked or not?
James McMillan OP  @Reply  
    
3 years ago
What is the VBS code to lock a SPECIFIC RECORD, not a table, or field or database, a single record in a table.
James McMillan OP  @Reply  
    
3 years ago
> What determines whether a record should be locked?

I am  a pilot training center and building  my database for electronic student records. The FAA requires are completing a training record, the record must be locked so it cannot be altered. If Access cannot accomplished that then I'll have to switch Oracle or go AI for answers, because I'm not getting any from Tech help.
James McMillan OP  @Reply  
    
3 years ago
This the answer AI gave me:
Private Sub FieldName_Exit(Cancel As Integer)
    Dim rs As Recordset
    Set rs = Me.RecordsetClone

    ' Search for the record you want to lock based on a unique identifier '
    rs.FindFirst "ID = " & Me.ID.Value
    
    If Not rs.EOF Then
        ' Lock the record to prevent other users from editing it '
        rs.Edit
        rs!Locked = True
        rs.Update
    End If

    rs.Close
    Set rs = Nothing
End Sub
Kevin Yip  @Reply  
     
3 years ago
The code is absolutely nonsensical.  It modifies a *field* named "Locked" instead of actually doing what you want.  ChatGPT is not yet reliable in code generation, as I've seen time and time again.  It doesn't seem to even understand what is actually requested of the code, let alone generating it reliably.  Give it another 5 years or less and maybe it will do better.

Other posters and I have already given you suggestions on how to do this in the other thread you started, so you should consider those instead.
Alex Hedley  @Reply  
           
3 years ago
Richard Rost  @Reply  
          
3 years ago
Alex Hedley  @Reply  
           
3 years ago

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/2/2026 8:28:14 AM. PLT: 0s