P
Pendragon
(Access 03)
I have two recordsets which are getting the appropriate data. The first
recordset, rsAddress, is a list of IDs (and other data) found in the second
recordset, rsAltAddress, which need to be deleted from the second recordset.
set rsAltAddress = MyDB.OpenRecordset("Select * from IndivsAltAddress Order
By IndivsAltAddress.IndivID")
In IndivsAltAddress, IndivID is an indexed field with duplicates allowed.
What I need to do is for each record in rsAddress, go through all records in
rsAltAddress and if the IndivID in each is a match, then delete the entire
record from rsAltAddress.
In the code below, I get through the first iteration of the embedded
DO...LOOP. After the .MoveNext and the LOOP, upon entering the condition
statement again, the loop exits and errors with Error 3167: Record deleted.
I've looked at and varied the statements so much I'm now completely lost.
Guidance is truly appreciated.
The code:
rsAddress.MoveFirst
rsAltAddress.MoveFirst
With rsAddress
Do While Not rsAddress.EOF
With rsAltAddress
Do While Not rsAltAddress.EOF
If rsAddress("IndivID") = rsAltAddress("IndivID") Then 'THIS IS
WHERE IT ERRORS ON THE SECOND ITERATION
.Delete
End If
.MoveNext
Loop
End With
rsAddress.MoveNext
Loop
End With
Thanks!!!!
I have two recordsets which are getting the appropriate data. The first
recordset, rsAddress, is a list of IDs (and other data) found in the second
recordset, rsAltAddress, which need to be deleted from the second recordset.
set rsAltAddress = MyDB.OpenRecordset("Select * from IndivsAltAddress Order
By IndivsAltAddress.IndivID")
In IndivsAltAddress, IndivID is an indexed field with duplicates allowed.
What I need to do is for each record in rsAddress, go through all records in
rsAltAddress and if the IndivID in each is a match, then delete the entire
record from rsAltAddress.
In the code below, I get through the first iteration of the embedded
DO...LOOP. After the .MoveNext and the LOOP, upon entering the condition
statement again, the loop exits and errors with Error 3167: Record deleted.
I've looked at and varied the statements so much I'm now completely lost.
Guidance is truly appreciated.
The code:
rsAddress.MoveFirst
rsAltAddress.MoveFirst
With rsAddress
Do While Not rsAddress.EOF
With rsAltAddress
Do While Not rsAltAddress.EOF
If rsAddress("IndivID") = rsAltAddress("IndivID") Then 'THIS IS
WHERE IT ERRORS ON THE SECOND ITERATION
.Delete
End If
.MoveNext
Loop
End With
rsAddress.MoveNext
Loop
End With
Thanks!!!!