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 
Locking an Order
Mark Pierce 
     
5 years ago
I want to have a lock and unlock record editing button on several forms. I used the below code based on what I learned from the Orders template here on 599.

This worked on my first form but I tried to duplicate it on another form by updating the MainAssem_1 form to the MainAssem_3 form. For some reason this code doesn't work on any other form.

any ideas whats wrong?



Private Sub LockifLockRecord()

  If IsLockRecord Then
        Me.AllowEdits = False
        Me.AllowDeletions = False
        MainAssem_1.Form.AllowEdits = False
        MainAssem_1.Form.AllowDeletions = False
        MainAssem_1.Form.AllowAdditions = False
    Else
        Me.AllowEdits = True
        Me.AllowDeletions = True
        MainAssem_1.Form.AllowEdits = True
        MainAssem_1.Form.AllowDeletions = True
        MainAssem_1.Form.AllowAdditions = True
    End If


End Sub

Private Sub Form_Load()
    Me.LockRecord = True
    Me.Refresh
End Sub

Private Sub Form_Open(Cancel As Integer)

End Sub

Private Sub Lock_Click()
     Me.LockRecord = True
  
End Sub

Private Sub PrintCurrentForm_Click()

End Sub

Private Sub RecordLock_Click()
    Me.LockRecord = True
    Me.Refresh
    
End Sub

Private Sub UnLock_Click()
    Me.LockRecord = False
  
End Sub

Private Sub UnLock_Record_Click()
    Me.LockRecord = False
End Sub
Richard Rost  @Reply  
           
5 years ago
It's funny that you posted this just now because AS WE SPEAK I'm getting ready to upload a TechHelp video and Template that I just recorded today about record locking. This is a totally different topic. You're talking about locking an order because it has been shipped which we covered in Developer 23. In your case, you don't have to change all of those properties for the subform. Just lock the subform itself. Should be:

MainAssem_1.Locked = True

And also, LockRecord is a FIELD, right? You don't need "Me." in front of it. It's confusing. Makes people think that's a property or an event, which it's not. If you want to use the Me, say

Me!LockRecord

Which indicates it's a field. See Bang v Dot.
Adam Schwanz  @Reply  
            
5 years ago
If the form name is MainAssem_3 then look here, somethings not right :P

  If IsLockRecord Then
        Me.AllowEdits = False
        Me.AllowDeletions = False
        MainAssem_1.Form.AllowEdits = False
        MainAssem_1.Form.AllowDeletions = False
        MainAssem_1.Form.AllowAdditions = False
    Else
        Me.AllowEdits = True
        Me.AllowDeletions = True
        MainAssem_1.Form.AllowEdits = True
        MainAssem_1.Form.AllowDeletions = True
        MainAssem_1.Form.AllowAdditions = True
    End If
Alex Hedley  @Reply  
           
5 years ago
Did you just copy/paste the code from one form to another?
Check the events are bound from Design View.
They might not be hooked up/connected.
Mark Pierce OP  @Reply  
     
5 years ago
Adam,
the form that the code works on is MainAssem_1, when I copied the code over to MainAssem_3 and updated the form name to MainAssem_3  on the code it wouldnt work on Form 3.
Adam Schwanz  @Reply  
            
5 years ago
Your have MainAssem_1.Form in the code. If the form it's being used on is MainAssem_3 that's at least part of your problem. If you've fixed that. I'd check that you actually have events like alex said on the form. Make sure they say [Event Procedure] and aren't blank. Or if it's a subform, just do like Rick said and lock the whole subform, simpler.
Mark Pierce OP  @Reply  
     
5 years ago
Thanks for the the response Alex.
Yes I just copied and pasted from one form to another. I checked the events, I event removed them and recreated everything by hand.
Mark Pierce OP  @Reply  
     
5 years ago
Richard,
I just watched the record locking video you make today and yes its not exactly related to my issue.

Using a different form I created an LockRecord button and a UnlockRecord button and placed them on the form.

Private Sub RecordLock_Click()
MainAssem_Part_4.Locked = True
End Sub


Private Sub UnLock_Record_Click()
MainAssem_Part_4.Locked = False
End Sub

However I get the below error when I try to use either of the buttons.

I get Run-time error '424':
Object required
Richard Rost  @Reply  
           
5 years ago
What is MainAssem_Part_4? Without knowing what your objects are, I can't help. Is that the name of your subform object?
Richard Rost  @Reply  
           
5 years ago
Look at my TechHelp Free Template. Go to the Customers with Contacts form. If you put a button on the parent form that says:

ContactF.Locked = TRUE

Then it will lock the subform. That's how you do it. Real simple. One line of code. Check your spelling. Remember this is the name of the SUBFORM OBJECT inside of the form. It's not the actual name of the Form in your Navigation Pane.
Mark Pierce OP  @Reply  
     
5 years ago
Richard,
MainAssem_Part Forms that contain serial number to part numbers fields and assembly instructions. So when I am saying MainAssemb_Part_4 I am referring to a form that is based on specific assembly instructions.
I am trying to prevent the tech. person from accidently modifying data once it has been entered on a new record for each form. I had to recover some record data due to this issue.

So the end goal is for Tech. to have to click something off and on for each assembly form Part to make sure they are on the correct record.

also I want records to be locked from edit on form load.

hopes this makes more sense.
Mark Pierce OP  @Reply  
     
5 years ago
Richard,
I think the issue is that I didn't communicate well enough, I want to lock both the sub form and the parent form.

I tried this and it worked as you said for the SubForm
ContactF.Locked = TRUE
Juan C Rivera  @Reply  
            
5 years ago
WOW I do this also with some of my forms, I use a checkbox IsRecLock  (hidden) use button to unlock and lock the current record (Allow Edits) true/false  don't know if this will help

V/r
Juan

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:12:11 AM. PLT: 1s