Setting Employee Access Levels

A

alan_mitchell

Hi,

Here's the situation.

I have some VB code (GetUserName) which pulls in the username of the user
from the Windows API. I then have a table which contains the desired access
levels for each employee. The fields are:

* EmployeeName (text)
* AllowedAccessToControlA? (yes/no)
* AllowedAccessToControlB? (yes/no)
* AllowedAccessToControlC? (yes/no)

So for example, Joe Bloggs might be allowed access to A and B but not C.

I now want to make controls on a form visible/not visible based on these
access levels. So if the user is Joe Bloggs, I would want to make controls A
and B visible, but control C invisible.

I can't think of an easy way to do this but I'm sure there must be one. Any
ideas?

Thanks for your help!

Alan
 
D

Daniel Pineault

You really should implement User-Level Security (ULS) on your db from there
you will be able to control what each user or group can view\edit\...

Don't reinvent the wheel. The tool already exist. Look it up in the help
file or online there is tons of information on the subject and it is easy to
setup and use.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
A

alan_mitchell

Rick Brandt said:
In the OpenEvent of the form...

Me.ControlA.Visible = DLookup("AllowedAccessToControlA",_
"TableName",_
"EmployeeName = '" & GetUserName() & "'")
Me.ControlB.Visible = DLookup("AllowedAccessToControlB",_
"TableName",_
"EmployeeName = '" & GetUserName() & "'")
Me.ControlC.Visible = DLookup("AllowedAccessToControlC",_
"TableName",_
"EmployeeName = '" & GetUserName() & "'")

This is a simple example. I generally avoid making multiple consecutive
domain aggregate calls so more likely I would use a Recordset object so I
could retrieve all three values with one query instead. The concept is
the same though.


Thanks Rick - it worked a treat!

Cheers,
Alan
 

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