Apply Filter For Specific Users

  • Thread starter Thread starter Jade
  • Start date Start date
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
 
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
 
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
 
Back
Top