Filter on Current User???

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?
 
A

Allen Browne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top