Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Track Changes    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Run Time Error
Michael Albert 
      
10 months ago
I have a procedure to log changes to certain fields in a form.
If I modify an existing record, everything works great, but if I am adding a new record  I get the following:

Run Time Error '94':
Invalid Use of Null

---------------------------------------------------------------------------------
Private Sub StatusCombo_BeforeUpdate(Cancel As Integer)
    
    LogIt Forms!FPR03aTasks!TPR02aSubProjName, TPR03aTskDescription, StatusCombo.OldValue, StatusCombo.Column(1), "", "", TPR03aTskID
  
    
End Sub
----------------------------------------------------------------------------------
Public Sub LogIt(TPR04aSubApp As String, TPR04aDesc As String, TPR04aStatFrom As String, TPR04aStatTo As String, TPR04aPrtyFrom As String, TPR04aPrtyTo As String, TPR04aRecID As String)
    
    
    Dim S As String

    S = "INSERT INTO TPR04aChgLog (TPR04aSubApp, TPR04aDesc, TPR04aStatFrom, TPR04aStatTo, TPR04aPrtyFrom, TPR04aPrtyTo, TPR04aRecID) " & _
            "Values (""" & TPR04aSubApp & """, """ & TPR04aDesc & """, """ & TPR04aStatFrom & """, """ & TPR04aStatTo & """, """ & TPR04aPrtyFrom & """, """ & TPR04aPrtyTo & """, """ & TPR04aRecID & """)"
        
   DoCmd.SetWarnings False
   DoCmd.RunSQL S
   DoCmd.SetWarnings True
  
End Sub
--------------------------------------------------------------------------------
Sami Shamma  @Reply  
             
10 months ago
Message box S and see which value is coming across as null. Make sure either in the table or in the form, the default value for that is either a blank or a zero.
Richard Rost  @Reply  
          
10 months ago
Yeah, one of the values you're passing in is NULL and you can't do that unless you declare the parameters are Variants. In that case, you can Nz them inside the LogIt sub.
Richard Rost  @Reply  
          
10 months ago
I'm gonna guess it's your StatusCombo.OldValue. It probably doesn't have a value on the first run.
Michael Albert OP  @Reply  
      
10 months ago
Thank you gentlemen. Worked great.
Mike

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Track Changes.
 

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: 4/21/2026 10:15:54 AM. PLT: 1s