What is wrong? Can you interpret this for me?

  • Thread starter Thread starter L Morgan
  • Start date Start date
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
 
Let's start with "what error are you getting?" so that we have some idea of
what the problem is.
 
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?
 
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.
 
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
 
Back
Top