Filter on Current User???

  • Thread starter Thread starter Jonathan Smith
  • Start date Start date
J

Jonathan Smith

I have an Access 2002 database, in Access 2000 File Format.
The User must LOGON with a UserName and a Password, from a Table within the
Database.

I would like to be able to record the User who inputs the data on Forms,
and then restrict the Editing of those Forms to the User who initially
input the data?

Any suggestions?
 
Presumably you have stored the user's name somewhere after login, and you
have a field in this table to identify which user the record belongs to.

In the Open event of the form, set its RecordSource. This is safer than
applying a Filter (since the user can turn that off). You will also need to
assign the DefaultValue property of a hidden text box for the user field, so
your database records who entered this record.

Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = "SELECT * FROM [MyTable] Where [User] = """ & SomeUser
& """;"
Me.[User].DefaultValue = """" & SomeUser & """"
End Sub
 
Back
Top