Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2014

    Unanswered: Run-time error '94': Invalid use of Null

    In Access 2010 I have created a form to update a DB and I would like to check for duplicate entries in a specific field (AR Number) before moving on in the form. I found the below code and modified it for my use, however, if any input is entered into the AR Number field and then the user backspaces (deletes) the entry and then moves to another field in the form I get the Run-time error '94': Invalid use of Null. The code works great other than when this specific condition happens. I would like for the information to be able to be erased if the user makes an error.

    The code is entered into AR_Number BeforeUpdate. I have underlined the portion that is returned as an error during debug. Any help would be greatly appreciated.

    Private Sub AR_Number_BeforeUpdate(Cancel As Integer)

    Dim SID As String
    Dim stLinkCriteria As String
    Dim rsc As DAO.Recordset
    Set rsc = Me.RecordsetClone
    SID = Me.AR_Number.Value
    stLinkCriteria = "[AR Number]=" & "'" & SID & "'"
    'Check StudentDetails table for duplicate StudentNumber
    If DCount("AR_Number", "AR Tracker", stLinkCriteria) > 0 Then
    'Undo duplicate entry
    'Message box warning of duplication
    MsgBox "Warning Action Request " _
    & SID & " has already been entered." _
    & vbCr & vbCr & "You will now been taken to the record.", vbInformation _
    , "Duplicate Action Request"
    'Go to record of original Student Number
    rsc.FindFirst stLinkCriteria
    Me.Bookmark = rsc.Bookmark
    End If

    Set rsc = Nothing
    End Sub

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    So screen out NULL values
    put an if statement that includes that code if the value is not null

    If not isnull(ar_number) then
    Set rsc.....
    ...set rsc....
    'Insert code to handle null values if required
    end sub
    I'd rather be riding on the Tiger 800 or the Norton

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts