Current User

  • Thread starter Thread starter Joy
  • Start date Start date
J

Joy

If multiple users use the same form to edit hours entered in a time and
billing database, is it possible to prevent a user from viewing other
users/employees hours worked. What I'm trying to do is identify if the
current user selecting the employee name is selecting his or her own name.
Then if not, and the user is not in the
Admins group, the form won't open and they can't see what other employees
have done. Only a user in the Admins group would be permitted to view all
records.

The database is created in Access 2003 and is secured. It has group level
security (2 groups - Admins and Users) and each user has a copy of the
front-end on their pc. The users/employees select their name from a drop
down box on a form, then the hours form opens listing projects and hours
logged for the employee selected.

Any help is appreciated.
Thanks.
 
Since you have used the built-in Users Group, your database isn't secure.
That group is common to all mdw files, so anyone can open your database
using any workgroup file. The Admins Group is fine, but you need to create
your own group for the users.

Then since your users will be logging in, you can identify them using the
CurrentUser() function. They don't need to select their name from a
combobox.

You can set the recordsource of your form when it opens depending on the
group the current user is in. There is a function in the security FAQ you
can use to determine if the current user is in the Admins Group.
http://support.microsoft.com/?id=207793

If faq_IsUserInGroup("Admins", CurrentUser) then
Me.RecordSource = "SELECT * FROM YourTable;"
Else
Me.RecordSource = "SELECT * FROM YourTable WHERE WhoOwns = " & chr(34) &
CurrentUser() & chr(34)
End If

This assumes that you add a field called WhoOwns in YourTable to identify
the employee for the record.
 
Back
Top