Apply Filter For Specific Users

J

Jade

I have a form where I want employees to only be able to
see records that are their own. There's an employee name
field. I set a password and users for the db and thought
that maybe I could apply a filter so that the employee
name field would equal the username of the person logging
into the db. But is there a way to reference the
username? Or is there an easier way of going about
this. Thanks for the help in advance.

Jade
 
A

Adrian Jansen

You will have to have a field in your employee table filled with the actual
username for each. Then you can set up a form filtered by UserName(), and
it should only show the matching record.


--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
A

Allen Browne

If you have set up Access security, CurrentUser() will give you the name of
the logged in user.

A user with very little knowledge could click the Remove Filter toobar
button to remove a filter. It may be better to use the form's Open event to
dynamically change it's RecordSource, e.g.:

Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = "SELECT * FROM MyTable Where [EmployeeName] = """ &
CurrentUser() & """;"
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