siddhusingh1968
New member
- Local time
- Today, 01:54
- Joined
- Apr 9, 2011
- Messages
- 7
I have this code to sequence dates in an Access db. It grabs the end date of the first record and pastes it into the start date of the next record and so forth. I need to modify this code to sequence the dates from the current record i.e. where the cursor is instead of going to the first record. I get a NULL error for the PREVDATE value when I try to do that. What am I doing wrong? Please.
***CODE****
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
Dim PREVDATE As String ' will hold value of end date from previous record in this variable
If rst.RecordCount <> 0 Then
End If
rst.MoveFirst 'moves cursor to first record
Do
'Add code to trap t2TaskDuration null values to update to arbitrary number of 8 or so...
PREVDATE = rst.Fields("t2Plan_End")
rst.MoveNext ' test
If Not rst.EOF Then
rst.Edit
rst.Fields("t2Plan_Start") = DateAdd("d", 1, PREVDATE)
rst.Fields("t2Plan_End") = rst.Fields("t2Plan_Start") + rst.Fields("t2TaskDuration")
rst.Update
Else
Exit Do
***CODE****
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
Dim PREVDATE As String ' will hold value of end date from previous record in this variable
If rst.RecordCount <> 0 Then
End If
rst.MoveFirst 'moves cursor to first record
Do
'Add code to trap t2TaskDuration null values to update to arbitrary number of 8 or so...
PREVDATE = rst.Fields("t2Plan_End")
rst.MoveNext ' test
If Not rst.EOF Then
rst.Edit
rst.Fields("t2Plan_Start") = DateAdd("d", 1, PREVDATE)
rst.Fields("t2Plan_End") = rst.Fields("t2Plan_Start") + rst.Fields("t2TaskDuration")
rst.Update
Else
Exit Do