Results 1 to 2 of 2
  1. #1
    kelkan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    26

    change on form with VBA produces errorcode Run-time error '94': Invalid use of Null

    I am trying to have a form update certain fields based on the user changing a field value. Below is the code that I have written.

    Private Sub CBOCOMPLETE_AfterUpdate()
    If IsNull(CLASSDATE) Then
    CLASSDATE = InputBox("You must enter the date this class was completed.")
    End If

    If CLASSCOMPLETED = "YES" Then
    Me.CLASSHOURS = Me.COURSEHOURS
    ElseIf CLASSCOMPLETED <> "YES" Then
    Me.CLASSHOURS = 0
    End If

    Dim strdate As String
    strdate = DateAdd("M", Me.FREQUENCY, Me.CLASSDATE)



    If Me.COURSECATEGORY = "PRIMARY CERTIFICATION" And Me.CLASSCOMPLETED = "YES" Then
    Me.EXPIRATIONDATE = strdate
    ElseIf COURSECATEGORY = "SECONDARY CERTIFICATION" And Me.CLASSCOMPLETED = "YES" Then
    Me.EXPIRATIONDATE = strdate
    ElseIf Me.COURSECATEGORY <> "PRIMARY CERTIFICATION" Or "SECONDARY CERTIFICATION" And CLASSCOMPLETED = "YES" Then
    Me.CLASSHOURS = Me.COURSEHOURS And Nz(EXPIRATIONDATE)

    End If

    On Error Resume Next

    End Sub

    This works fine if the class has an expiration date. Unfortunately, many of my classes do not have or require an expiration date and that's when I get the error message. Ideas on how to correct?

  2. #2
    kelkan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    26
    Disregard - I made some minor changes and fixed it myself...

    Private Sub CBOCOMPLETE_AfterUpdate()
    If IsNull(CLASSDATE) Then
    CLASSDATE = InputBox("You must enter the date this class was completed.")
    End If

    If Me.CLASSCOMPLETED = "YES" Then
    Me.CLASSHOURS = Me.COURSEHOURS
    ElseIf Me.CLASSCOMPLETED <> "YES" Then
    Me.CLASSHOURS = 0
    End If


    Dim strdate As String
    strdate = DateAdd("M", Me.FREQUENCY, Me.CLASSDATE)
    If Me.COURSECATEGORY = "PRIMARY CERTIFICATION" And Me.CLASSCOMPLETED = "YES" Then
    Me.EXPIRATIONDATE = strdate
    End If

    If Me.COURSECATEGORY = "SECONDARY CERTIFICATION" And Me.CLASSCOMPLETED = "YES" Then
    Me.EXPIRATIONDATE = strdate
    End If

    If Me.COURSECATEGORY = "MANDATORY" Or Me.COURSECATEGORY = "OPTIONAL" And Me.CLASSCOMPLETED = "YES" Then
    Nz (EXPIRATIONDATE)
    End If

    On Error Resume Next
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 12-08-2012, 04:56 PM
  2. Error 94: Invalid Use of Null
    By athomas8251 in forum Forms
    Replies: 3
    Last Post: 11-09-2011, 11:46 AM
  3. DLookUp function giving invalid use of null error
    By shubhamgandhi in forum Programming
    Replies: 4
    Last Post: 07-21-2011, 06:04 PM
  4. Replies: 0
    Last Post: 02-22-2011, 04:18 PM
  5. Run-Time Error 3044 - Invalid Path?
    By KrenzyRyan in forum Import/Export Data
    Replies: 8
    Last Post: 01-19-2011, 10:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums