Prevent the user from using F4 to delete a record

Hello All What approach should I take to prevent a user from pressing F4 and confirming the deletion of a record in a subform, if that particular record consists of another field that is set to TRUE for example. i.e. If a check box is set to TRUE, I do not want the user to be able to delete that particular record. - For example in an order form. All other records in that order form can still be deleted if their particular check box is not ticked. I have no problems in preventing modifications of fields within records, but how do I prevent deletion of an entire record? Thanks

Put some code in OnDelete, this should do the trick… you can not disable the F4 key, if this is what you want.

Hi David! What about this Form-OnDeleteRecord() : Boolean TESTFIELD(CheckBoxField, FALSE); Regards, Jörg

To prevent the user from pressing F4 you can do like this. Put a menubutton on the subform. (Put it under the tablebox, so the user doesn’t see it.). Create a menuitem “Remove” with a ShortCutKey of F4. Put this code under the menuitem: IF NOT CheckBox THEN IF CONFIRM('Delete %1?',FALSE,TABLECAPTION) THEN DELETE(TRUE); This will not prevent the user from being able to delete the record though. The user can always mark the line and press the DELETE-button or choose Delete in the edit-menu. To prevent the user from deleting records you have to put code in the OnDelete trigger of the table or form.

Hi Magnus! Cool trick! [8D] Once in a blue moon I yield to the temptation of saying “you can’t do xxx”, and voila! someone shows me how to do “xxx”… [:I]

Hi All, Thank you all for your advice - I will keep this for the future. In the end I have used Jorg’s approach as this does exactly what I need. Thanks, that is great! Cheers David