Protect a single record

Numpty

on t'internet
Local time
Today, 10:50
Joined
Apr 11, 2003
Messages
60
IS there anyway to protect a single record so that it cannot be deleted?

The main way a user would delete a record would be from a button on the form - I've coded the button so it's disabled when that particular record comes up but the user could select the delete record option from the Edit menu. I don't know how to go about disabling that without taking out the whole menu.

Any pointers greatly appreciated.

Cheers
 
How about using the Before Del Confirm and After Del Confirm events to trap record deletions on the form?
 
you could run a check on what's being deleted using the 'before delete confirm' setting in the form's properties, and then cancel the delete if it is the one you're trying to protect.

Also, you could add a 'do not delete' field flag on the base table that you set yourself and this way you could protect numerous records by checking for this flag vefore deleting.
 
If you can determine which record or records you do not want to delete. You can use the Form_Current Event and set the Form.AllowDeletions property. Test for the desired record or records and set the property.

Here's a test with a prompt you can try yourself


If MsgBox("Lock Deletions", vbYesNo, "TEST") = vbYes Then
Me.AllowDeletions = False
Else
Me.AllowDeletions = True
End If


Good Luck. Let me know how it works
 
Cheers for the replies.

I've put it into the On Delete event to check for the ID of the particular record.

Works fine.

Thanks
 

Users who are viewing this thread

Back
Top Bottom