Limit user access to certain forms or reports

hfsitumo2001

Member
Local time
Today, 10:35
Joined
Jan 17, 2021
Messages
394
Helo, Anyone can help me how to make that certain users can only access certain forms or reports. In my login table I have:
  1. UserID
  2. UserName
  3. Password
  4. Accesstype
Thank you

Frank
 
In the Open event of your form, check the user's permission and either continue to open the form or show a message box and cancel the form from opening.
 
In the Open event of your form, check the user's permission and either continue to open the form or show a message box and cancel the form from opening.
Thanks George, but I do not know what is the VBA for this, probably lookup the table and the User access type and than say if.... then open, other Msg Box.

Thank you

Frank
 
This is more to authorize to the table, but I want to start opening a form thru my switchboard menu, then there will be a check on opening the form.

Thank you
I have never seen the logic of presenting a user with a choice, only to say they cannot use it, when they try to do so?
 
In a separate table, define what user levels has access to your forms using a yes no field. The employee can simply login and the employee ID can be saved as a temporary variable. Each form can have a DLookup to that looks for the employee and whether that particular employee has access to the form being opened.
 
how if we want it to be more than one form or report.

You have one user table with some indicator of each user's role. It could be "Admin" or "Supervisor" or "Auditor" or "Mechanic" or ... whatever things your employees do. You could use a code instead of a role name. Immaterial to the process, just be consistent in how you use it.

If you have a login form, or if you use an Opening Form to be a dispatcher or switchboard, you look up the user role based on the user ID. Store that either in a public variable in a general module or in a TempVar. Your choice as to which method you wish to use. But you keep that value where it is usable for as long as that user's session is active. Erase that info when the user logs out, unless Access is also exiting at that time. In which case everything is being erased anyway.

Then you decide for each form/report ... FOR EACH ONE INDIVIDUALLY ... which roles should have access to that form/report.

Then for each one item, you have the Form_Open or Report_Open event look at the user's information in that place where you stored the role.

Then you have, in each _Open routine,

Code:
IF UserRole <> "Admin" AND UserRole <> "Supervisor" THEN
    Cancel = 1
    Exit Sub
End If
.... other things that the _Open routine might need to do...

There are fancier ways but if you have multiple roles, multiple forms, and multiple reports, and there is no uniformity, you have to do SOMETHING individual and therefore a bit tedious.
 

Users who are viewing this thread

Back
Top Bottom