Can't Prevent Deletion of Data

S

Swaggel1

I have created a simple form for data entry. Users must be able to
enter and update data, but not delete any information.

I have tried preventing deletion of data through the use of User-Level
Security (I did not give users permission to delete data from the
underlying table), through adding a "Cancel = True" event procedure to
the On Delete property of the form, and by setting the Allow Deletions
property of the form to No.

After each of these attempts, users are still able to delete, delete,
delete. I am obviously doing something wrong - does anyone see my
error? Any help would be greatly appreciated!
 
R

Rick Brandt

Swaggel1 said:
I have created a simple form for data entry. Users must be able to
enter and update data, but not delete any information.

I have tried preventing deletion of data through the use of User-Level
Security (I did not give users permission to delete data from the
underlying table), through adding a "Cancel = True" event procedure to
the On Delete property of the form, and by setting the Allow Deletions
property of the form to No.

After each of these attempts, users are still able to delete, delete,
delete. I am obviously doing something wrong - does anyone see my
error? Any help would be greatly appreciated!

If you have set the form property AllowDeletions to "No" then they should not be
able to make deletions with the form. Have you tested this?
 
J

John Vinson

After each of these attempts, users are still able to delete, delete,
delete. I am obviously doing something wrong - does anyone see my
error? Any help would be greatly appreciated!

Just to clarify:

Can a user open a table containing 100 records, delete a record, close
the form, and find 99 records in the table?

Just what is it that they are deleting?
 
S

Swaggel1

To answer your question.....I have tested the use of the form for
deletion of data. The User, who I have tried to block from deleting
data numerous ways, is able to use the form to delete any and all
fields that appear on the form. When I go into the underlying table
to determine if the information is gone, it is gone. I just went
through this exercise logged in as a User, and I was able to delete
every bit of information from the table.
 
R

Rick Brandt

Swaggel1 said:
To answer your question.....I have tested the use of the form for
deletion of data. The User, who I have tried to block from deleting
data numerous ways, is able to use the form to delete any and all
fields that appear on the form. When I go into the underlying table
to determine if the information is gone, it is gone. I just went
through this exercise logged in as a User, and I was able to delete
every bit of information from the table.

Ok I think I get it now. Clearing a field is considered an edit, not a
deletion. A Delete is when the entire record is removed from the table. A
record still in the table that just happens to have Null in all of its
fields is not considered deleted.

What you need are settings of Required = Yes on the table and/or validation
rules on the fields that prevent blank entries.
 
J

John Vinson

To answer your question.....I have tested the use of the form for
deletion of data. The User, who I have tried to block from deleting
data numerous ways, is able to use the form to delete any and all
fields that appear on the form. When I go into the underlying table
to determine if the information is gone, it is gone. I just went
through this exercise logged in as a User, and I was able to delete
every bit of information from the table.

Rick's answer is (as usual) bang on. It's a jargon confusion: this
user is not *deleting the record*, but editing the field values.

Is this user authorized to update the contents of the record, say to
correct erroneous data? If not, set the AllowEdits property of the
form to False also. If the user has some sophistication in Access, you
may well need to invoke Access security on the database, and put him
in a group with no update rights to this table (since he could just
close the form and open the table datasheet directly, if he wants to
damage your data).
 
S

Swaggel1

Rick Brandt said:
Ok I think I get it now. Clearing a field is considered an edit, not a
deletion. A Delete is when the entire record is removed from the table. A
record still in the table that just happens to have Null in all of its
fields is not considered deleted.

What you need are settings of Required = Yes on the table and/or validation
rules on the fields that prevent blank entries.

This makes sense. Now I understand why setting the Allow Deletions
property to No wasn't working. I think this clarification will help
greatly. However, to complicate matters, I can't require all of the
fields to be filled, because it's OK for the fields to be blank for
some situations. I just want to prevent users from deleting any
information that might have already been input. Is this possible?
 
R

Rick Brandt

Swaggel1 said:
"Rick Brandt" <[email protected]> wrote in message

This makes sense. Now I understand why setting the Allow Deletions
property to No wasn't working. I think this clarification will help
greatly. However, to complicate matters, I can't require all of the
fields to be filled, because it's OK for the fields to be blank for
some situations. I just want to prevent users from deleting any
information that might have already been input. Is this possible?

A validation rule on the controls of the form of "is not null" would allow a
user to leave a field blank when creating the record, but would not allow them
to clear the field once an entry was made in that control. Perhaps that can
work for you.

Otherwise you could use the BeforeUpdate event of the form. You would need a
code block that would examine the entirety of the record after editing and
decide whether it is a "legal" change to the record. In cases where it is not,
the change can be prevented by setting Cancel = True. The challenge is coming
up with the rules for what is allowable and what is not and being able to
implement them in your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top