Forms: User Resctrictions

ohappyday

Registered User.
Local time
Today, 15:00
Joined
Aug 6, 2009
Messages
20
Ok, I have searched and searched for the answer to my issue and I can't find a previous thread that will help....

My code is not working... :(

I created a login form for my Access 2007 db which requires each user to login. Once they are logged in, I want them to have access to certain forms based on the 'Privilege' I have assigned to each user.

The Analysts table contains the user login information as well as the assigned 'Privilege'.

Privileges: FSSTechnician and FSSManager
FSSTechnician is not allowed to access form - FSSManagers, but FSSManager is allowed to access this form.

Here is my code:

Private Sub FSS_Manager_Click()
Dim Privilege As String
Username = DLookup("[Privilege]", "Analysts")
If "[Privilege]" = "FSSManager" Then
DoCmd.OpenForm "FSSManagers", acNormal, , "[Privilege]='FSSManager'"
Else
MsgBox "You do not have access to this area.", vbCritical
End If
End Sub

What am I doing wrong?


Thanks!
 
Thanks for the response.

I will take a look at the db you sent.
 
Hi JPaulo -

If your 'Identificacao' was String instead of an Integer, how would you change your code?

I am getting type mismatch errors.

Thanks
 
Can't get it to run with your example, but I think I may know why?....

I have a field 'Privileges' that I also wanted to incooperate along with username and password.

I want the code to verify the username and password are correct. Based on the username, I want the code to perform a dlookup in the 'Analysts' table for the the "Privilege' that is assocated with the Analyst and open a form for that privilege.

So if the user has 'Type A' Privilege, I want the 'Type A Privilege Form' to open. If the user has Type B' Privilege, I want the 'Type B Privilege Form
to open.

Note: the Privilege is not a data entry field, just an additional field in the Analysts table.

Clear as mud? Sorry...

Please help...
 
Hi JPaulo -

Happy New Year!

I just used your code in the sample database and it worked just fine.

Thanks so much for your help!
 
i suspect the reason your code wasnt working was this

Username = DLookup("[Privilege]", "Analysts")

i am not sure what this is intended to do, but what it would do is look up the value for privilege in the table analysts, but would return any value, probably the first. But the privilege value returned would be stored in the variable username

if you are trying to find the privilege for a given user then the code needed is more like this

privilegesetting = dlookup("privilege","analysts","userid = " & someuser)
 
Hi -

Yes, you are correct. I used JPaulo code to get me started, but I tweaked it a little to make it work for me.

Thanks so much for responding!
 
Thanks friend for the answer.

I'm happy to work.
 

Users who are viewing this thread

Back
Top Bottom