Free Lessons
Fast Tips
Topic Index
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
Home > Courses > Access > Templates > Record Locks
Back to Access Record Locks Template    Comments List
Invalid Use of Null Upload Images   Link   Email  
Ruud Schildknegt      
3 years ago
record locking template gives an error when you add a product. How can I solve this?
Ruud Schildknegt      
3 years ago

Richard Rost             
3 years ago
I checked it out. I'm surprised nobody has caught this yet. Turns out that the code WILL throw an Invalid Use of Null error when you go to add a new record. It's trying to LOCK a Null OrderDetailID. So we can fix that by simply checking for a Null and exiting the sub if that's the case. Add one line to the start of the sub:

Private Sub Form_Dirty(Cancel As Integer)

    If IsNull(OrderDetailID) Then Exit Sub

    If IsRecordLocked(OrderDetailID, "OrderDetailT") Then
        Cancel = True
        LockRecord OrderDetailID, "OrderDetailT"
        LockRecord OrderID, "OrderT"
    End If
    doFormLocked Me
End Sub

That record doesn't need to be locked yet if it's new because it won't show up in the table for anyone else anyhow until it's committed after editing.
Adam Schwanz             
3 years ago
Sorry I fixed mine a while ago and completely brushed off that it was something in the template that I should maybe tell you about LOL. Assuming a few people did that.
Richard Rost             
3 years ago
Gee... thanks, Adam. :/
Adam Schwanz             
3 years ago
I'm so helpful :) LOL
Ruud Schildknegt      
3 years ago
I've been puzzling for a while but can you guys tell me if there is a way to lock the subform as soon as 1 record is added or changed in the subform?
Richard Rost             
3 years ago
You can set a maximum number of records for a related table (subform) using DCount and a Before Insert event. That's actually going to be in today's TechHelp video. Should be posted later today.
Adam Schwanz             
3 years ago
What about tempvars? :) LOL
Richard Rost             
3 years ago
Ruud: See today's Extended Cut video on DCount

Adam: What about it?
Adam Schwanz             
3 years ago
I was making a joke about wanting to bump up the tempvars Techhelp :P.

Richard Rost             
3 years ago
Adam: Ah. Funny. Ha. Ha. Ha. :)

Ruud: See the Extended Cut for today's DCount video.
Ruud Schildknegt      
3 years ago
I had no success with the dcount command. After quit a puzzle i solved it by using BeforeInsert event with a simple code:

    If IsRecordLocked( 'parentid' , "table") Then
        doFormLocked Me
        doFormUnlocked Me
    End If

this lockes the source table of the subform so no one can edit or add records on the subform

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Record Locks Template.


The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 7/19/2024 9:06:31 AM. PLT: 1s