Delete particular record if user of form the record creator?

kate10123

Registered User.
Local time
Today, 07:22
Joined
Jul 31, 2008
Messages
185
Hi there,

I have a tutorial history form which allows tutors to view their tutorials and delete any that were created in error.

The trouble is, at the moment my delete code allows users to delete any tutor records when really it should just be there own.

Code:
If MsgBox("Are you sure you want to delete this record?", vbYesNo, _
    "Confirmation Required") = vbNo Then
        'SendKeys "~"
        Exit Sub
    End If
    
    On Error Resume Next
    DoCmd.RunSQL ("DELETE * FROM [tbl_Tutorial] WHERE " _
    & "(([tbl_Tutorial].[TutorialNo])=" & Me!List14.Column(0) & ")")
    
   List14.Requery

How can I validate the user so that only the current user of the database can delete their particular records only and no others?

I have a login screen which requires the user to select their name from a combo box and then the system checks their selection against the PC username, if this matches then they can enter the system.

So I have the username available as a variable I just don't know how to write a routine for this.
 
One option would be to save the user on a form textbox, then have your listbox rowsource use that control as a criteria so the user only sees their own activity.
 
Thanks for replying.

I had a button on the form 'filter by tutor' . This then changes the listbox to show only that particular tutors records in.

I wrote a simple IF condition around this and it is working!
 

Users who are viewing this thread

Back
Top Bottom