Hi, 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
rst.MoveLast
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
Else
btnNext.Enabled = False
btnPrevious.Enabled = True
End If
End Sub
-----------------------------------------------
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
rst.MoveLast
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
Else
btnNext.Enabled = False
btnPrevious.Enabled = True
End If
End Sub