Can't you delete the records with just a single SQL statement? Something like..
DELETE * from table Where (Description = "Sensor OFF") AND (ID in (Select ID from table where Code = "Sensor ON"))
If so, then your code can be as simple as...
Code:
DoCmd.RunSQL SQLStatement
If you don't want the user to be warned of the deletion, then...
Code:
DoCmd.SetWarnings False
DoCmd.RunSQL SQLStatement
DoCmd.SetWarnings True
You will have to adequately quote the SQL statement. So...
DoCmd.RunSQL "DELETE * from Table Where (Description = ""Sensor OFF"") AND (ID in (Select ID from table where Code = ""Sensor ON""))"
Notice the double quotes ("") for the embedded quotes.
Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org