I am needing to evaluate a record set and remove records. My table has multiple Records with Unique Effective Dates by Action. I need to compare each record to the next record and remove the record in the table if the Action in the record below it is equal. I started with a simple OpenRecordset for printing to identify database and record set below. I am a beginner of Access/VBA
Code:
EFFDT ACTION 8/23/2015 PLA 12/4/2015 PLA Need to remove 3/6/2016 RFL 10/18/2018 PLA 1/28/2019 PLA Need to remove 6/9/2019 RFL
Code:
Public Sub OpenRecordset() Dim db As Database Dim rs As Recordset Set db = CurrentDb Set rs = db.OpenRecordset("tblLOA") '---------Work in Process for evaluating Records and Delete Last = rs.MoveLast For i = Last To 2 Step -1 If (Fields(i, "Action").Value) = (Fileds(i - 1, "Action").Value) Then Fields(i, "Action").EntrieRow.Delete End If '-------------------------------------------------------------------------------------- For i = 0 To rs.RecordCount - 1 Debug.Print rs.Fields("ACTION") rs.MoveNext Next i rs.Close Set rs = Nothing db.Close
Comment