A97.
Simplified description: I have a query which returns one field containing
numbers.
I have a table where one field contains the same numbers as the query
(amongst others). The query and the table are not related in any way.
I want to loop through each record in the query, find matching records in
the table and delete them. The code counts the correct number of records
(5073) provided I comment out the delete command - if the delete command is
executed then the number of records deleted is about 3400. Here's an
extract from the code:
With rs1 'The Query
.MoveFirst
Do Until .EOF Or .BOF 'Do this until the end of the query
strCriteria = "[DRG_VER] = '" & rs1!DRG_VER & "'" 'Get the DRG_VER
from the query
rs2.MoveLast
rs2.MoveFirst
rs2.FindNext strCriteria 'Find a DRG_VER in the BUILD_ACT_TBL
that matches that from the query
If rs2.NoMatch = False Then 'There is a match
intCount = intCount + 1
Debug.Print intCount & " " & rs2![DRG_VER]
'rs2.Delete
End If 'There was no match
'rs2.FindNext strCriteria
.MoveNext 'Move to the next record in the query
Loop
End With
I've tried liberal sprinklings of MoveLasts and MoveFirsts and even tried
wrapping it all up into a transaction but to no avail. Can anyone advise?
Many thanks,
Keith.
www.keithwilby.com