Invalid use of null with no (obvious) Null values

tatarik

Registered User.
Local time
Today, 15:15
Joined
Mar 4, 2013
Messages
29
Hi people :)

It might be an easy one but I just wasted the past hour deciphering through my code in order to solve the run-time error '94' that I'm getting when trying to execute the following code:
:banghead:
Code:
Private Sub cmdUpdateDates_Click()
'###################################
'This sub aims at combining the timesheet date and the start and end time into the fields [Start Time] and [End Time]. 
'###################################
Dim intCounter As Integer
intCounter = 0
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

Dim strSQL As String
strSQL = "SELECT tblTest.[Start Time], tblTest.[End Time], tblTest.[Timesheet Date] FROM tblTest " & _
"WHERE (((tblTest.[Start Time]) Is Not Null) AND ((tblTest.[End Time]) Is Not Null) " & _
"AND ((tblTest.[Timesheet Date]) Is Not Null))"

rs.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockPessimistic

rs.MoveFirst
Do Until rs.EOF
            If IsNull(rs![Start Time]) Or IsNull(rs![End Time]) Or IsNull(rs![Timesheet Date]) Then
            GoTo RsMoveNext
            Else
            End If
            
            rs.AddNew
            rs![Start Time] = DateSerial(year(rs![Timesheet Date]), month(rs![Timesheet Date]), day(rs![Timesheet Date])) + TimeSerial(hour(rs![Start Time]), minute(rs![Start Time]), 0)
            
            If hour(rs![Start Time]) <= hour(rs![End Time]) Then
                        rs![End Time] = DateSerial(year(rs![Timesheet Date]), month(rs![Timesheet Date]), day(rs![Timesheet Date])) + TimeSerial(hour(rs![End Time]), minute(rs![End Time]), 0)
                        Else
                        rs![End Time] = DateSerial(year(DateAdd("d", 1, rs![Timesheet Date])), month(DateAdd("d", 1, rs![Timesheet Date])), day(DateAdd("d", 1, rs![Timesheet Date]) + 1)) + TimeSerial(hour(rs![End Time]), minute(rs![End Time]), 0)
            End If
            
            rs.Update
            intCounter = intCounter + 1
            
RsMoveNext:
            rs.MoveNext
Loop

rs.Close
Set rs = Nothing

MsgBox (intCounter & " date(s) have been modified. ")
End Sub

Any idea what is happening here?

Cheers

T.
 
Sorry quys.

I just solved the problem :S

This:
rs.AddNew
.. was unnecessary.

:)
 

Users who are viewing this thread

Back
Top Bottom