I have a basic recordset coding problem that is stumping me. I want to flip a SELECT flag whenever the IDNUMBER changes, but this would be the last date associated with that IDNUMBER. Here's what I've started:
Dim Dbs As DAO.Database
Dim rst As DAO.Recordset
Set Dbs = CurrentDb()
Set rst = Dbs.OpenRecordset("tblStudent_Summary", dbOpenDynaset)
rst.MoveFirst
Do While Not rst.EOF
rst.Sort = "IDNUMBER, DATE asc"
'For Each rst In .Recordsets
With rst
If rst![IDNUMBER] <> rst![IDNUMBER] Then
rst![Select] = -1
Else
End If
End With
rst.MoveNext
Loop
Set rst = Nothing
Set Dbs = Nothing
End Sub
But where the problem is that I don't know how to declare the previous IDNUMBER and the currentIDNUMBER in the code. I think that I'm only a line or two away from getting this to work. Sure would appreciate your help.
Dim Dbs As DAO.Database
Dim rst As DAO.Recordset
Set Dbs = CurrentDb()
Set rst = Dbs.OpenRecordset("tblStudent_Summary", dbOpenDynaset)
rst.MoveFirst
Do While Not rst.EOF
rst.Sort = "IDNUMBER, DATE asc"
'For Each rst In .Recordsets
With rst
If rst![IDNUMBER] <> rst![IDNUMBER] Then
rst![Select] = -1
Else
End If
End With
rst.MoveNext
Loop
Set rst = Nothing
Set Dbs = Nothing
End Sub
But where the problem is that I don't know how to declare the previous IDNUMBER and the currentIDNUMBER in the code. I think that I'm only a line or two away from getting this to work. Sure would appreciate your help.