Deleting records


#1

I use the Datasheet all the time for accounting purposes; it fantastic, but the danger I find is that I can unwittingly delete a record (by clicking on a selected field and pressing the Delete key) when I wanted to delete the data in a field (i.e. by double clicking on the selected field and pressing the Delete key). There is no warning when deleting records e.g. a Warning! dialog “Delete Record OK?”

Can I write a procedure so that if I delete a record in the Datasheet a warning dialog appears for me to approve the deletion.


#2

Create a procedure named exactly .DeleteRecord

Enter something like:

If info("Modifiers") notcontains "option"
    Beep alertcanceldelete "Are you sure you want to DELETE this record?"   
    If info("DialogTrigger") ≠ "Delete"
	    Stop
    EndIf
EndIf
DeleteRecord

The procedure will run every time you try to delete a record, except if the deletion is via a procedure.


#3

Thank you James, the procedure works properly.

Much appreciated.


#4

You may have realized it, but I failed to point out that as I wrote it, if you want to deliberately delete a record, holding the Option key deletes without the interruption of the confirmation dialog.


#5

Thank you James. Just what I needed.