Hello all,
Im looking for some help with duplicate records. I have a table that gets updated on a daily basis but each day the same record could show up on the table creating a duplicate.
On the table i have a load date field so i can tell which record is old and new. What im trying to do is carry over the info from the new record to the old one keeping the original load date and then delete the new duplicated record. I have writen some code that can remove the duplicates with no problem but i am having trouble getting it to edit the old record. I can get it to work with static data but having trouble getting it to look at the table data.
any help would be greatly appreciated.
thanks in advance,
Slen
here is what i have so far
Im looking for some help with duplicate records. I have a table that gets updated on a daily basis but each day the same record could show up on the table creating a duplicate.
On the table i have a load date field so i can tell which record is old and new. What im trying to do is carry over the info from the new record to the old one keeping the original load date and then delete the new duplicated record. I have writen some code that can remove the duplicates with no problem but i am having trouble getting it to edit the old record. I can get it to work with static data but having trouble getting it to look at the table data.
any help would be greatly appreciated.
thanks in advance,
Slen
here is what i have so far
Code:
Dim myDB As DAO.Database
Dim rst As DAO.Recordset
Dim strFind As String
Set myDB = CurrentDb
Set rst = myDB.OpenRecordset("tableName", dbOpenDynaset)
With rst
Do While Not .EOF
If Not IsNull(![ID]) And ![Status] = "Open" Then 'Check for Duplication
strFind = DCount("*", "tableName", "[Status] ='" & "Open" & "' AND [ID] = '" & ![ID] & "' And [Status2] = '" & ![Status2] & "' And [LoadDate] <=#" & ![LoadDate] & "#") > 1
If strFind Then
.Edit
'here is where im trying to figure out what to insert
.Update
End If
End If
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
Set myDB = Nothing
Comment