Restricting delete record in a form

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

Guest

I have a form which is using a table as the source data. One record in the
table contains the number 0 and the second record the number 1. Users can add
records to the table but I don't want them to delete either of these values.
Can I protect the values in the form and the table as well? The table name is
Routes and the field is RouteNum.

Thank you.
 
I have a form which is using a table as the source data. One record in the
table contains the number 0 and the second record the number 1. Users can add
records to the table but I don't want them to delete either of these values.
Can I protect the values in the form and the table as well? The table name is
Routes and the field is RouteNum.

Thank you.

You can (and probably should) set the AllowDeletes property of the
form to True; this will prevent deletion from the table altogether.

A sneaky way to protect these two records is to create another table
with one numeric field (of the same datatype as this one); make this
field its Primary Key, and add two records, 0 and 1. Create a
Relationship from your table to this table, joining primary key to
primary key - a one to one relationship. You don't need any additional
records; a one to one is more precisely a one-to-(zero or one)
relationship. Hide this other table. These two records will not be
deletable, since it would violate the referential integrity.

John W. Vinson[MVP]
 
Back
Top