Limit user from accessing a specific form

cooh23

Registered User.
Local time
Today, 04:37
Joined
Dec 5, 2007
Messages
169
I am having a problem restricting a user from a certain form.
I have a module that detects if a user or admin based on the roles entered in the employees table.

If their windows login is not listed in the employees table, they will not be able to view any of the forms.

Here's my problem, I want the users to access the switchboard, but they should not be able to get into the reporting button.

here's my code:
Code:
    If LOAStatusbtn.Caption = "View Report" _
        And Not admin _
    Then
        'useraccess denied because not an admin
        error_text = "You do not have privileges to access this screen." & vbCr & "Please contact an administrator"
        MsgBox error_text, , "No Privileges"
       
    End If

If they click on LOAStatusbtn and their role is not admin, then a message should pop up.

I searched the forum and could not find anything similar to this.

Thank you,
 
If you set the on open procedure for your form so that if the current user <> admin then reportingbutton.visible=false. This will only hide the button for people that aren't admins. The only problem is I don't know if your db tracks who is logged on. If so you can use the current user name or number as the ID and whether or not they are an admin. Hope this helps. Post again if you need clarification.
Tyler
 
If you set the on open procedure for your form so that if the current user <> admin then reportingbutton.visible=false. This will only hide the button for people that aren't admins. The only problem is I don't know if your db tracks who is logged on. If so you can use the current user name or number as the ID and whether or not they are an admin. Hope this helps. Post again if you need clarification.
Tyler

Sorry, I don't quite understand what you meant. I did forget to mention that I have a module that i call on every form to check user's credentials. Whether they are a user or an admin.

My module is called GetUserInfo()

But I don't want a particular form to be viewed by the user.

Thanks,
 
In my database I have created a shell database that's sole function is to determine the user's level of access based upon their Hash ID (personal ID) that is in the registry some where. When the employee logs into the computer it stores their ID number THis database has a form that just reads the Hash ID from the computer and then says that if the Hash ID's permission level is 1 then they can only read. From my understanding of your problem you want to keep a certain employee from accessing a button that takes them to a form. Is that right? As long as there aren't other ways for them to open the reporting form you can control access by controling their access to the button. If you are in design mode and you right click on the upper left corner of the form you can get to the form's on open event procedure. In that proceedure you will as you said: "I have a module that i call on every form to check user's credentials" Good. Use the user credential and say that if user credential is not equal to (<>) Admin then CommandButton4.Visible = False (the name of the button to the form) This will hide the button for that person. In my DB I have three user levels set. I have certain buttons and functions that are only visible or active if their user level is 2 or 3 but not 1. You can have a table in your back end named login and have their ID number in one field and their permission level in the next and then reference that level in the button. That will allow you to keep anybody out that isn't set to the Admin level. I found this works well when there are alot of employees and most have a similar access level. Hopefully this helps you. Let me know otherwise,
Tyler:)
 
In my database I have created a shell database that's sole function is to determine the user's level of access based upon their Hash ID (personal ID) that is in the registry some where. When the employee logs into the computer it stores their ID number THis database has a form that just reads the Hash ID from the computer and then says that if the Hash ID's permission level is 1 then they can only read. From my understanding of your problem you want to keep a certain employee from accessing a button that takes them to a form. Is that right? As long as there aren't other ways for them to open the reporting form you can control access by controling their access to the button. If you are in design mode and you right click on the upper left corner of the form you can get to the form's on open event procedure. In that proceedure you will as you said: "I have a module that i call on every form to check user's credentials" Good. Use the user credential and say that if user credential is not equal to (<>) Admin then CommandButton4.Visible = False (the name of the button to the form) This will hide the button for that person. In my DB I have three user levels set. I have certain buttons and functions that are only visible or active if their user level is 2 or 3 but not 1. You can have a table in your back end named login and have their ID number in one field and their permission level in the next and then reference that level in the button. That will allow you to keep anybody out that isn't set to the Admin level. I found this works well when there are alot of employees and most have a similar access level. Hopefully this helps you. Let me know otherwise,
Tyler:)

Thank you, I will try when I come back to work.
I have a table in the backend with the ID's, Names, and Roles (Users & Admins)

I'll post back with the results.

Thank you!
 

Users who are viewing this thread

Back
Top Bottom