Protect only certain records from deletion

G

Guest

A front-end user(User1) does all the data entry. He/she can delete any record.
The next user (User2) validates only certain records by checking a check
box. This box cannot be seen by User1.
User1 must not be able to delete the validated records, at this point User1
can.
How can I prevent User1 from deleting any record except the validated ones?
 
A

Allen Browne

Presumably there is a yes/no field named something like "IsValidated" in
your table. You want to prevent User1 from deleting any record where this
field is Yes.

Even though User1 cannot see the IsValidated field, it is still there, so
you can cancel the Delete event of the form where User1 inputs/edits the
records.

The code in the Event Procedure for the Delete event of the form will look
like this:

Private Sub Form_Delete(Cancel As Integer)
If Me.IsValidated.Value Then
Cancel = True
MsgBox "Already validated", vbExclamation,"Permission denied"
End If
End Sub
 
G

Guest

The Name of the Yes/No field is "Enrolled"
I replaced my field name in the coding.

My coding for the Delete event is:

Private Sub Form_Delete(Cancel As Integer)
If Me.Enrolled.Value Then
Cancel = True
MsgBox "You cannot delete this record!", vbExclamation, "Permission
denied"
End If
End Sub

When I try to delete the record an msgbox displays:
"Compile error. Method or data member not found."

and the word "Enrolled" is highlighted in the coding.

Thank you for your help.
 
A

Allen Browne

First, double-check that the Enrolled field is present in the form's
recordsource. For example, is the form based on a query? Is the field in the
query?

If yuou are sure it is there, and the spelling is consistent (double-L?),
then try a bang (!) in place of the dot (.):
If Me!Enrolled.Value Then
Access can sometimes be fastideous about that. (I suspect it's actually a
bug with the AccessField type.)
 

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