how to disable a control on another form base on user login

evanark

Registered User.
Local time
Today, 08:46
Joined
Jan 4, 2013
Messages
69
Hi, I am still new to Access VBA and was wondering if you could help me. I created a user login form that checked the value of a dropdown box for user name and text box for password. I have a table called privileges that has the following fields ID, username, password, and privilege level. The privilege level field can have one of two values one being "Admin", the other being "User". Once the user enters the username and password and clicks login, the main form opens. What I am trying to accomplish is if the current user that logged in has a privilege level of "User", the Admin options button on the main form is disabled and if the user has a privilege level of "Admin", the Admin options button on the main form is enabled. I have a few users with the "Admin" level and some with the "User" level. I can't seem to figure out how to accomplishes this task. Can anyone help me or show some example code. Thanks!
 
What I like to do is something like hide the login form, don't close it. That way you always have, at your finger tips, information about who the logged in user is. Then for all other processes in your system you can run code in the Current event of a form, and disable or enable things as you see fit for the current user.
Code:
private sub form_current()
[COLOR="Green"]   'button is enabled if the value of the UserRole on the login form = "admin"
   'and disabled in other cases
[/COLOR]   me.cmdRestricted.Enabled = (Forms("frmLogin").UserRole = "Admin")
end sub
Cheers,
 
I figured it out, I need to get some values from my login form, I was closing the form instead of hiding it once the login button is click, I keep getting a error saying it could not reference the form. It's a learning process :)
 

Users who are viewing this thread

Back
Top Bottom