What is wrong? Can you interpret this for me?

L

L Morgan

Private Sub Form_Load()
Dim db As Database
Dim rs As Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM TimeSheet WHERE SocialSecurity
='" & SocialSecurity & "'")
rs.MoveFirst

While Not rs.EOF
T_SickVal = T_SickVal + rs.Fields(9).Value
T_HolidayVal = T_HolidayVal + rs.Fields(8).Value {the error is in
this line}
T_VacationVal = T_VacationVal + rs.Fields(7).Value
rs.MoveNext
Wend

'Release Memory
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing

End Sub
 
K

Ken Snell MVP

Let's start with "what error are you getting?" so that we have some idea of
what the problem is.
 
S

SuzyQ

I don't know, but is it possible...

Could it be that your fields(8) is not a number. Count starts at 0??? why
not use actual field names?

What is the error message?
 
J

John W. Vinson

On Fri, 15 May 2009 09:24:01 -0700, L Morgan <L
Private Sub Form_Load()
Dim db As Database
Dim rs As Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM TimeSheet WHERE SocialSecurity
='" & SocialSecurity & "'")

This is looking for a VBA variable named SocialSecurity; there probably isn't
one.

Try Me!SocialSecurity if there is a form control of that name.
 
B

Bob Quintal

Run time error 94
Invalid use of Null
T_HolidayVal = T_HolidayVal + rs.Fields(8).Value

Invalid use of null means that
1) You have failed to Dim T_HolidayVal,
2) you Dim'ed it but did not initialize it to 0
3) The value for the referenced column in the timesheet table is null

Q
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top