Not allow deletion of record with criteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table in an Access 2000 db with one field with two required numbers
in two records, zero and 1. The user can add add new records but if they try
to delete either or both of these records, I want to revoke delete privledges
for these two records. Is that possible and if so, help please with the code.
The field name is Route.

Thank you.
 
I forgot to mention the user will be accessing the table via a command button
so I could associate the code with the button.
 
If you are using a command button, then presumably this is happening in a
form.

The form has a Delete event that fires when a record is being deleted. You
can cancel that event to block the deletion.

This example assumes the required fields is a Number type field named ID:

Private Sub Form_Delete(Cancel As Integer)
If Me.ID = 0 Or Me.ID = 1 Then
Cancel = True
MsgBox, "Oh, one cannot be deleted. :-)"
End If
End Sub
 
Back
Top