User privileges in acesss

apprentice

Registered User.
Local time
Today, 03:07
Joined
Jan 13, 2015
Messages
27
I have a security access table with two fields; "Admin" and "User"
Also a table with login data

My login form works perfectly... when an end user log in the codes look up to see if its admin access or user access then opens a navigation form with many sub forms - access are given to some forms based on user privileges.

However, i will like to enable and disable certain fields in those sub-forms based on user privileges.
 
If you can successfully restrict users to the forms they should/should not have, I think you would use a similar logic to restrict certain controls on a form they should have access to.
If a user has access to a Form, then I suspect you will have to disable and/or hide a control to which he/she has no access (even though they have access to that form).
 
Understood. the issue i am having restricting access to controls in a sub-form. Example, in the navigation form i have several sub-forms within those buttons on the main form which i can use to disable access to certain sub forms.

Example;
If user access = 1 then
DoCmd.Open form "Navigation"
Forms![Navigation]!NavigationButton11.Enabled = False

- NavigationButton11 has a sub form and i want to restrict access to controls within that form based on useraccess levels.

I hope this help explain my situation
 
If user level is 1 i want to disable a command button in the navigation button (sub form) and not the navigation button itself.
 
How do you populate the various navigation buttons? Do you create your own SQL?
 
Last edited:
Can you post a copy of your database ---remove anything confidential first?
Just need enough data to illustrate the issue.
I'm not real familiar with Navigation form, but my best guess at the moment would be to adjust the sql to not populate a control. But maybe you need separate navbutton.

This free video may give you some ideas. It deals with navform and navbuttons vs subforms and tab controls.
 
I got throught using this code; Forms.Navigation.NavigationSubform1.Form.Command297.Enabled = False
 
So, it's working?
 
I have found that the EASIEST (not necessarily the best) way is to put your user security code in a general module and make some public variables in the declaration portion of the module. At that point, any form or report can reference the public variables for tests of same. So if you had variables to hold (for example only)

Code:
Dim sCurUserName as String
Dim sCurUserRole as String

then you could call the routines that do the lookup using your main form's Form_Open routine to call the security lookup routines and have them leave behind what you need to know about your current user. (Even better if you have a switchboard form that stays open for the duration of a session, as you can let the switchboard Form_Open routinefill in those blanks.)

Once you have identified the user's role, you can do a Cancel of the Form_Open if the person is not an admin but a form requires admin-only access. That is how you would stop someone from opening a form that is off-limits.

Now, the next part of the puzzle is if you are going to disable certain (but not all) controls for non-admins. Do that trick from the Form_Load event routine of the form OR SUB-FORM as required. You can do the security check from Form_Open, but the controls are not necessarily available to you at that time. They ARE available in Form_Load or, for bound forms, Form_Current.

It is sufficient to just set a control.Enabled=False to turn off a control. It will become "greyed out." Of course, for admins, you would want set the control.Enable=True just to be sure.

Just to finish off the topic, if it happened that you needed to further restrict a user's access so that non-admins could only see their own department's data, all you would need is to know the user's department (perhaps as another field from your user role table) and add a public variable for that, too. You could then test for departmental restrictions in Form_Current, because by that time the current record has been registered in the form and you can test its values.
 

Users who are viewing this thread

Back
Top Bottom