Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete criteria

Status
Not open for further replies.

luceze

Programmer
Apr 26, 2001
842
US
I have a data entry form with records that have some fields already populated. I was wondering if there was any way that I could check to see if any original data is in the record and deny deletion of that record. I want them to be able to delete records that they have added. I've tried the before and after delete confirm functions but they aren't triggering. Is there something I'm doing wrong?

Here's my code for the before delete:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)

If Me.ThisYrAmend <> 0 Then
msgbox &quot;Sorry, but you're not allowed to delete&quot;, vbOKOnly, &quot;Delete&quot;
Cancel = True
End If

End Sub
 
You can set the data source of the form so that it matches the &quot;created by&quot; field with the CurrentUser() function so that they can only see/edit their records, and then you don't have to worry so much about the tricky (imperfect) code solution.

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
That way won't work because other users have to be able to edit and see other users input. I ended up having to use a pop up form to decide whether the delete button is available for certain records then by your answer in my other post I am able to delete only those records that I want to allow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top