By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,806 Members | 1,465 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,806 IT Pros & Developers. It's quick & easy.

Restricting Update of a Record to the User who Created the Record

P: 2
This is my first time posting in a forum for Access, but I've seen a lot of great answers on this site so I'm hoping I can get one for this question.

I have an Access database that allows users to store notes. Every time a new note is added, Access stores the userID of the user who created the note in a table, tblNotes, in the column, NoteCreator. I do this with the CurrentUser function in the BeforeUpdate event procedure.

I want to know if there is a way, since the creator of the note is already stored, to only allow the creator of the note to update it, and not other users. Currently, if I use the built-in security features of Access, anyone I give permission to update tblNotes can update anyone's notes. Basically, I want to write code that goes something like this, but I don't know the right commands in VBA:

Expand|Select|Wrap|Line Numbers
  1. If CurrentUser = NoteCreator Then
  2.     allow update
  3. End If
I hope this is possible since it would be a much better solution than allowing all users to update any record, or preventing any user from updating a single record.

Feb 14 '07 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 15k+
P: 31,489
Try using the form's BeforeUpdate event procedure :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.     Dim strUser As String
  4.     strUser = "" 'Wherever you get this from
  5.     If strUser <> Me!NoteCreator Then
  6.         Call MsgBox("Warn user")
  7.         Cancel = True
  8.     End If
  9. End Sub
Feb 14 '07 #2

P: 2
Thanks, that worked perfectly.
Feb 15 '07 #3

Expert Mod 15k+
P: 31,489
I'm very pleased to hear it.
And you're welcome btw.
Feb 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.