on Afterunlock event delete item

If an item i click save_as ,  how to delete the duplicate item on afterunlock event,

i write a code on afterunlock event ,

the following:

Dim test as Item = Me.newItem(itemtype,"delete")

test.setAttribute("where","id = '" & id & "')

test = test.apply()

There should be errors: No items of type MaintainPlan found.

need you help,appreciate.