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...
If you don't want the user to be warned of the deletion, then...
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