If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Run-time error 94: Invalid Use of Null

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-20-09, 11:29
rbchoi rbchoi is offline
Registered User
 
Join Date: Sep 2009
Posts: 2
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
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
Reply With Quote
  #2 (permalink)  
Old 09-23-09, 02:18
kristle.sison26 kristle.sison26 is offline
Registered User
 
Join Date: Feb 2009
Posts: 23
First make your "On Error" a comment line so it will highlight the line where error arise.
Code:
'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.

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

Good Luck
Reply With Quote
  #3 (permalink)  
Old 09-23-09, 09:16
rbchoi rbchoi is offline
Registered User
 
Join Date: Sep 2009
Posts: 2
I re-created the whole thing and now it works -- thanks so much for your help anyways!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On