delete

  • Thread starter Thread starter Joel Allen
  • Start date Start date
J

Joel Allen

Hello,

Based on certain criteria, I want to prevent someone from deleting a task.
How can I do this. Would I make some sort of prevention like this? This
doesn't work though. Can you please help?
Function Item_BeforeDelete(ByVal Item)

Item_Write = False

Msgbox "You can't delete this!"

End Function



Thanks,

Joel
 
Hi Joel Allen,
Based on certain criteria, I want to prevent someone from deleting a
task. How can I do this. Would I make some sort of prevention like
this? This doesn't work though. Can you please help?
Function Item_BeforeDelete(ByVal Item)

Item_Write = False

Should not this be Item_BeforeDelete = False
 
The signature for the BeforeDelete method is: BeforeDelete(Item As Object,
Cancel As Boolean). To use it you would set Cancel = true.

However, that event only applies if the item is open and the user deletes it
from the File menu (File, Delete). It does not apply when the user deletes
the item from a folder view or in any other way. Therefore it's not very
useful at all.

If you are using Outlook 2007 (always provide information when you post),
there is the new Folder.BeforeItemMove event that is perfect for what you
want. If you handle that event the MoveTo folder destination is null if the
item is being deleted and you can then set Cancel = true to prevent the
deletion.

With other versions of Outlook there really isn't a way to prevent deletions
in every case.

BTW, Item_Write has nothing to do with deletions and would not help you at
all and certainly can't be used from within a BeforeDelete event handler.
 
Thanks Ken, that was very helpful. I don't have 2007 yet, so I'll have to
use the other function BeforeDelete. Your response great though and I'll
use that method when moving to 2007.
 
Back
Top