By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,060 Members | 1,893 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,060 IT Pros & Developers. It's quick & easy.

How to make an Access login with rights to user information

P: 3
I want to create a login form for multiple users with different rights, and they can only see information in my queries and reports that pertain to them. For example: User1 logins in, on the switchboard I only want user1 to be able to see certain things. Then when user1 goes to see a report, it only shows user1, user1's information.

Now by what I have read and can gather, I will need a user table, and that table will have to have their username, password, and a rights level, but I have no idea how to put all of that into code in VBA to make it happen.
May 26 '10 #1
Share this Question
Share on Google+
4 Replies


P: 8
Hi newbornman, here's how I've handled this. On my main form (or switchboard) I capture the user's login and enable/disable, show/hide the boxes, forms and buttons I want each to have access to.

Expand|Select|Wrap|Line Numbers
  1. Dim usernm As String
  2. usernm = Environ("USERNAME")
  3. 'Debug.Print usernm
  4. If (usernm = "JohnSmith" Or usernm = "JoeSmith") Then
  5.  
  6. Me.txtReadOnly.Visible = False
  7. Me.txtReadOnly.Enabled = False
  8. Me.txtRecursive.Visible = True
  9. Me.txtRecursive.Enabled = True
  10. Me.txtRecursive.SetFocus
  11. Me.AllowAdditions = True
  12. Me.AllowEdits = True
  13. Me.AllowDeletions = True
  14. Me.btnOpenEditLog.Visible = True
  15. Me.btnOpenEditLog.Enabled = True
May 26 '10 #2

P: 3
Ok, so I need to take that code and put it into my VBA module, and then attach it to my login form? Does this make it to where one part of the company can only see their information? The reason I ask this, is because I am trying to make this for a company that has many parts.
For Example:
There are 8 companies. Company A, B, C, D, so on so forth.
There is one table with everyones information, and a whole bunch of queries and reports.
Company A logs on and goes to look at the reports. I want Company A to be able to only see Company A's information and not company B, or C or what anyone else.

If this code works then I apologize but like I said before I am new to this. Thanks for the help.
May 27 '10 #3

P: 8
I guess part of it depends also on the version of Access you are using. 2007 no longer has user-level security, so this has been my work-around, but I am dealing with only a few users. You could take that table with everyone's names and assign a permission level to each. For instance

NAME PERMISSIONS
Pam Company A
Greg Company A
Sam Company B

So when username is Pam or Greg, you enable and make visible only Company A forms, buttons, text boxes, etc. And you can also the send value 'Company A' into a variable to be used as the where condition when you open those forms so that they only see Company A data. I could send you that code later if you would like to see it--I forgot my laptop and someone is bringing it to me soon.
May 27 '10 #4

P: 3
Yes please for the code. As for everything else, thank you very much.
Jun 3 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.