How to restrict editing records to only the user who created them

  • Thread starter Thread starter missamay
  • Start date Start date
M

missamay

I have a set up Access security on a database containing two forms. One
that users can only create new records and one where they can edit
records. When a new record is created, I want the user's login (Access
login or Windows login) to be automatically entered in the form/table.
And when they open the Edit form I want them to only be able to view
and edit the records they created.

I have read an earlier post on this subject from 2004 and I tried the
code, but received errors that I could not resolve.

I also tried using the CurrentUser() function on the form, but could
not get the current user displayed from this function on the form to
transfer to the actaul data table.

Does anyone have any suggestions or code I could try? Thanks.
 
To store the current user, you must do so in a bound field. In other words,
the control on the form must be connected to an actual field in the table so
the user can be stored. You would then make that field default to the
current user (and I'd lock it so the user can't change it. Personally, I
would make it invisible. No need to let your users know it is there.

Then, the query that is used as the record source of your "edit form" just
needs to pull up all the records for that user. Just put criteria under the
"UserID" field with something like...
=CurrentUser()

Hope that helps.
 
Back
Top