Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009

    Unanswered: Run-time error 94: Invalid Use of Null

    Hi, I am working with a database in MS access and every time I try to open a form that is linked to another form, I get the "run-time error 94: invalid use of null" message. Below is the code that pops up when I click "debug". Can anyone figure out why I keep getting this message and how I can fix it? Much thanks!


    Private Sub Form_Load()

    Me.OrderBy = "[ID] ASC"
    Me.OrderByOn = True

    Dim rst As Object
    Dim rCount As Integer
    Set rst = Me.RecordsetClone
    On Error Resume Next
    On Error GoTo 0
    rCount = rst.recordCount

    Dim SName As String
    Dim SSurname As String

    SName = DLookup("SName", "Students", "SSN='" & StudentId & "'")
    SSurname = DLookup("SSurName", "Students", "SSN='" & StudentId & "'")

    lblNumEntry.Caption = "Student " & SName & " " & SSurname & " has " & rCount & " Intake records"

    DoCmd.GoToRecord , , acLast

    If rCount = 1 Then
    btnNext.Enabled = False
    btnPrevious.Enabled = False
    btnNext.Enabled = False
    btnPrevious.Enabled = True

    End If
    End Sub

  2. #2
    Join Date
    Feb 2009
    First make your "On Error" a comment line so it will highlight the line where error arise.
    'On Error Resume Next
    'On Error GoTo 0
    then tell us what line is highlighted so that it is easier to help you.

    Mostly, I encounter this error when giving value to a control from my record on database. When the result is zero or does not match to any record.

    Text1.text = rst!StudentID
    if rst!StudentID is null then that error message will pop-up

    Good Luck

  3. #3
    Join Date
    Sep 2009
    I re-created the whole thing and now it works -- thanks so much for your help anyways!

Posting Permissions

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